snag AGENTS.md

A project guide for AI coding agents working on snag, a command-line tool that fetches web pages through Chrome or Chromium. It describes setup, the project structure, supported browser modes, output formats, URL handling, tab selection, and installation of the agent skill.

In plain words
What is it for?
Use it when setting up or changing snag, fetching pages from URLs or existing browser tabs, handling authenticated sessions, or choosing Markdown, HTML, text, PDF, or PNG output.
Why use it?
It gives agents the project context and expected commands so they can work with browser sessions and web-page output correctly.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/p3bot/snag/agents-md
Clone the repo
git clone --depth 1 https://github.com/p3bot/snag

Made for: Codex, OpenCode.

Per session 4,723 This file is loaded in full into every session.
When invoked 4,723 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.04723 $0.04723
Opus 5 $0.02361 $0.02361
Sonnet 5 $0.00945 $0.00945
Haiku 4.5 $0.00472 $0.00472

Measured 2d ago against content hash 8291a34b392d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

snag AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 514 lines

How it starts

The opening of the file, as written. The whole thing — 514 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md

A README for AI coding agents - This document provides context and instructions for AI coding agents working on snag. For human contributors, see README.md.

Project Overview

snag is a CLI tool that intelligently fetches web page content using Chrome/Chromium via the Chrome DevTools Protocol (CDP). Built for AI agents to consume web content efficiently.

Key Features:

  • Auto-detect and connect to existing Chrome instances
  • Launch headless or visible browser modes
  • Handle authenticated sessions gracefully
  • Multiple output formats: Markdown (default), HTML, Text, PDF, PNG
  • Multiple URL support: Process multiple URLs in a single command
  • Tab management: List, select, and fetch from existing browser tabs
  • Pattern matching: Select tabs by index, exact URL, substring, or regex
  • Output directory support: Auto-generate filenames with timestamps
  • Single binary distribution, no extra runtime binaries or config files
  • Embedded agent skill (snag --skill) with user-initiated install via agentdex (catalog may use the network on first resolve; fail-closed; snag --skill never does)

Technology Stack:

  • Language: Go 1.25.3
  • CLI Framework: github.com/spf13/cobra v1.10.2
  • Browser Control: github.com/go-rod/rod v0.116.2 (Chrome DevTools Protocol)
  • HTML to Markdown: github.com/JohannesKaufmann/html-to-markdown/v2 v2.5.2
  • HTML to Text: github.com/k3a/html2text v1.4.0
  • Agent skills: github.com/p3bot/agentdex v1.1.0 (path authority for --skill-install / --skill-list / --skill-uninstall)
  • YAML: go.yaml.in/yaml/v3 v3.0.4 (skill frontmatter name)

Setup Commands

# Clone repository
git clone https://github.com/p3bot/snag.git
cd snag

# Install dependencies
go mod download

# Install
go install github.com/p3bot/snag/cmd/snag@latest

# Build binary
go build -o snag ./cmd/snag

# Run snag
./snag --version
./snag --help
./snag --skill

Build and Test Commands

# Build for current platform
go build -o snag ./cmd/snag

# Build with version info
go build -ldflags "-X github.com/p3bot/snag/internal/cli.Version=1.0.0" -o snag ./cmd/snag

# Run all tests (integration tests with real browser)
go test -v ./...

# Run specific test
go test -v ./... -run TestFetchPage

# Run with coverage
go test -v -cover ./...

# Test basic content fetching
snag https://example.com                # Fetch page as Markdown
snag --format html https://example.com  # Fetch as HTML
snag --format text https://example.com  # Fetch as plain text
snag --format pdf https://example.com   # Save as PDF (auto-generates filename)
snag --format png https://example.com   # Save as PNG screenshot (auto-generates filename)
snag -o output.md https://example.com   # Save to file

# Test multiple URL fetching
snag https://example.com https://google.com               # Fetch multiple URLs
snag -d output/ https://example.com https://google.com    # Save multiple with auto-generated names
snag -o combined.md https://example.com https://google.com # Combine into single file

# Test tab management features (Phase 2)
snag --open-browser                     # Open persistent browser (with DevTools enabled)
snag --list-tabs                        # List all open tabs
snag https://example.com                # Fetch URL (creates new tab)
snag --list-tabs                        # List tabs again (should show example.com)

# Tab selection by index (1-based)
snag --tab 1                            # Fetch from first tab
snag -t 2                               # Fetch from second tab (short form)

# Tab selection by pattern
snag -t "example.com"                   # Exact URL match (case-insensitive)
snag -t "example"                       # Substring/contains match
snag -t "https://.*\.com"               # Regex pattern match

# Tab features with output options
snag -t 1 --format html                 # Fetch tab 1 as HTML
snag -t "github" -o repo.md             # Fetch tab matching "github", save to file
snag -t 1 --wait-for ".content"         # Wait for selector in existing tab

# Cross-platform builds
GOOS=darwin GOARCH=arm64 go build -o snag-darwin-arm64 ./cmd/snag
GOOS=darwin GOARCH=amd64 go build -o snag-darwin-amd64 ./cmd/snag
GOOS=linux GOARCH=amd64 go build -o snag-linux-amd64 ./cmd/snag
GOOS=linux GOARCH=arm64 go build -o snag-linux-arm64 ./cmd/snag

# Code quality checks
go vet ./...
gofmt -l .

# Clean build artifacts
rm -f snag snag-*

Read the full file on GitHub · 514 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 514 lines · 4,723 tokens per session scan A 8291a34b392d

Subscribe to this mod's changes

snag AGENTS.md is an instructions file published in the GitHub repository p3bot/snag (73 stars, last pushed 3d ago), licensed MPL-2.0. It adds 4,723 tokens to every session, about $0.0236 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.