ai-chrome-extension-template
AGENTS.md10 starsChanged 4 months agoMITView on GitHub
This file is always in context — it stays lean. Task-specific detail lives in docs/ and is loaded on demand via the Routing table below. Load a doc only when its task applies. This repo starts as a template and becomes a real Chrome MV3 extension: the user runs /chrome-extension <idea> and you (the AI agent) build it end-to-end. If that skill is not available in your harness, read .claude/skills/chrome-extension/SKILL.md and follow it directly with the user's idea — it…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 32,671 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- chrome-extensionSkill
- chrome-extensionSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 50
Never commit secrets. Never hand-edit generated output (dist/, lockfiles).
- Distinctive: line 54
Evidence over memory: Verify Chrome APIs and library behavior against current docs or the installed source before building on them — …
- Very specific: line 61
Grow the tests with the product: Every feature adds a smoke assertion.
- Very specific: line 63
Persist state against context loss: Keep docs/architecture.md (module map, permissions rationale) and docs/decisions.md (choices + rejected …
- Very specific: line 82
After editing the canonical skill (.claude/skills/chrome-extension/SKILL.md), run npm run sync to regenerate the .agents/ and .codex/ …
≈ “Common” is an estimate: at least 1 in 5 of the 41,581 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent operating manual
This file is always in context — it stays lean. Task-specific detail lives in
docs/and is loaded on demand via the Routing table below. Load a doc only when its task applies.
The project
This repo starts as a template and becomes a real Chrome MV3 extension: the user runs
/chrome-extension <idea> and you (the AI agent) build it end-to-end. If that skill is
not available in your harness, read .claude/skills/chrome-extension/SKILL.md and follow
it directly with the user's idea — it is the master workflow (plan → build → test →
package → release).
src/— TypeScript extension source (strict; bundled by esbuild)public/— static assets (manifest.json, HTML pages) copied into the builddist/— built unpacked extension (gitignored; what the dev browser loads)tools/— Node dev-loop scripts (Node 22+; zero runtime deps)docs/— routed docs;docs/architecture.mdanddocs/decisions.mdare YOURS to maintain as the extension takes shape
The dev loop (every change runs through it)
npm run browser # launch/attach the dev browser (first run downloads Chrome for Testing)
npm run reload # BUILD + reload extension; exit 1 + the real error if new code fails to load
npm run smoke # e2e checks + screenshot — extend tools/smoke.mjs as you add features
npm run gate # format:check + lint + typecheck + tests (pre-commit hook runs this)
npm run stop # cleanly close the dev browserStandard iteration: edit → npm run reload → check → view
tools/screenshots/smoke-popup.png. Reload clears Chrome's sticky extension error log
first, so reported errors always belong to the current code. Ad-hoc probes:
node tools/send.mjs '{"type":"ping"}' (message the service worker),
node tools/shot.mjs [page.html] (screenshot any extension page). Full catalog:
docs/dev-loop.md.
Hard rules
- Never touch the user's personal browser — not their Chrome, profiles, or data. The
dev loop owns an isolated browser (
.dev-profile/, its own CDP port).npm run stoponly closes via that port. - The unpacked extension ID is derived from the load path: stable on one machine, never
portable. Read it from
npm run browseroutput orfindExtension()intools/cdp.mjs; never hardcode it. - Branded Chrome/Edge cannot side-load unpacked extensions (since v137). The dev browser
is Chrome for Testing by default;
BROWSER_EXEmay point only at a non-branded Chromium-family build. Details:docs/dev-loop.md. - Never commit secrets. Never hand-edit generated output (
dist/, lockfiles).
Working standards (always apply)
- Evidence over memory. Verify Chrome APIs and library behavior against current docs or the installed source before building on them — training knowledge goes stale.
- Small tasks, verified seams. Split work smaller than your first instinct; every task ends with a check you can run (reload exit code, smoke assertion, screenshot).
- The gate is law.
npm run gategreen before every commit; the pre-commit hook enforces it — never bypass with--no-verify. No magic numbers insrc/; files ≤500 LOC; low coupling (pure logic insrc/lib/–src/core/, chrome.* adapters at edges). - Grow the tests with the product. Every feature adds a smoke assertion; every pure
function gets a colocated
*.test.ts. - Persist state against context loss. Keep
docs/architecture.md(module map, permissions rationale) anddocs/decisions.md(choices + rejected alternatives) current; commit after every completed task so any future session resumes from git. - Brief subagents fully. They start with none of this context — name the exact doc paths they must read.
Routing — load a doc ONLY when its task applies
| When your task involves… | Read |
| Driving or verifying the extension in the dev browser (CDP, smoke, screenshots, diagnostics, troubleshooting) | docs/dev-loop.md |
| Versioning, packaging, cutting a release, CI | docs/release.md |
| Chrome Web Store submission (human-facing guide) | docs/chrome-web-store.md |
| Understanding or changing the extension's structure | docs/architecture.md |
| Recording or revisiting a design decision | docs/decisions.md |
| Running under OpenAI Codex (sandbox/network specifics) | docs/codex-setup.md |
Maintenance
After editing the canonical skill (.claude/skills/chrome-extension/SKILL.md), run
npm run sync to regenerate the .agents/ and .codex/ copies — never edit the copies.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

