{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiczggx3ws76wjjhuitjv7ivqezihpoybubw67pkfboyrmdtfbndqi",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mohzcljvh3k2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreih277utyudzolsescmhiwjeice66uc65w3druunidompek5ud7hia"
},
"mimeType": "image/webp",
"size": 339192
},
"path": "/gadz82/agent-contexts-a-tool-to-feed-you-coding-agents-5flm",
"publishedAt": "2026-06-17T09:08:32.000Z",
"site": "https://dev.to",
"tags": [
"ai",
"agents",
"coding",
"npm",
"agent-contexts",
"agent skills",
"github.com/gadz82/contexts",
"Vercel Skills",
"@nestjs"
],
"textContent": "In the AI era, something funny is happening: side projects that have been collecting dust in `~/code/wishful-thinking/` are getting dusted off. Suddenly that \"someday I'll write this\" repo on GitHub has a real README, a working CI, and three open issues you actually want to close.\n\nWhy? Because the AI doesn't complain. Doesn't get bored. Doesn't ask \"but why do we need this when we have X?\" at 11pm when all you want is to feel better with yourself, when your children are on the bed and you think \"now is the moment i should use to realize some of my personal projects.\"\nSo while the discourse is busy replacing you with LLMs, you're quietly using LLMs to replace the procrastination that used to replace you.\n\nThis post is about one of those moments, one of those ideas born in the night, that probably, in pre-AI era, would have been forgotten behind \"it's too late to open my laptop\": a small CLI called\nagent-contexts I wrote because I was sick of having 40 `AGENTS.md` tabs open across 40 different repos.\n\n## What Even Is \"Context\" and Why Should You Care?\n\nWhen you sit down with Claude Code, Cursor, Gemini CLI, or any of the other agentic tools, they don't read your mind. They need to be told things. Some of those things you tell them in chat. But the important stuff — the project conventions, the \"don't do this here\" rules, the \"we use tabs not spaces, fight me\" — should live **in the repo itself** , so every agent (and every teammate) picks them up automatically.\n\nDifferent agents have different conventions for where to look:\n\n * **Claude Code** looks for `CLAUDE.md` (and also `AGENTS.md`, because Anthropic isn't petty).\n * **Gemini CLI** looks for `GEMINI.md`.\n * **GitHub Copilot, OpenAI Codex, Cursor, and friends** use `AGENTS.md`.\n * A bunch of tools also support `.cursorrules` and similar.\n\n\n\nSo if you're running a polyglot agent setup (and who isn't these days)you're maintaining multiple files per project. That's annoying before you've written a line of code.\n\n## Context Is a Diet, Not a Buffet\n\nThe thing i learned the hard way: **bigger context does not equal better context**.\n\nWhen you feed your agent a 4,000-line `AGENTS.md` covering every\narchitectural decision from 2019 to today, two things happen:\n\n 1. The model gets slower and more expensive.\n 2. The model gets worse. Conflicting instructions, ancient context that's no longer relevant, edge cases from a code path that got deleted last year — all of it pollutes the \"what to do right now\" buffer.\n\n\n\nThe same project rarely wants the same context for every task:\n\n * **Building a new feature?** You want the architecture overview, the existing patterns, the conventions.\n * **Refactoring existing code?** You want the constraints, the dependencies, the \"this is load-bearing, don't touch\" notes.\n * **Hunting a bug?** You want the diagnostics playbook, the logging conventions, the test scaffolding.\n * **Onboarding a new dev (human or AI)?** You want the orientation guide: how to run things, where to look first, what's safe to change.\n\n\n\nSame repo. Four different `AGENTS.md` files. (Plus nested ones for\nsubfolders, because your `src/payments/` deserves its own context, thank you very much.)\n\nThe \"obvious\" solution at the beginning was one big monolithic `AGENTS.md` at the root... but soon you understand the unefficency of that approach. The other \"obvious\" solution currently is a hand-maintained tree of nested `AGENTS.md` files in every folder, it wins on quality but loses on maintenance. The day someone updates the root convention, they have to remember to propagate it. And nobody remembers.\n\n## Enter: Vercel's Skills\n\nThe Vercel team had a similar itch a while back, and they scratched it with agent skills. They treated the bundle of \"things an agent needs to do a job\" (instructions, scripts, references) as a package. So they made it installable. You can `npx skills add <source>`, the tool fetches the right files, drops them in the right places, and tracks what's installed in a lockfile. Deterministic, versioned, no fuss.\n\nBut skills are about _capabilities_ : \"here's how to run my CI\", \"here's how to deploy\", \"here's a script to seed the DB\". They don't really cover the `AGENTS.md` use case, where you want to distribute context, not behavior.\n\nSo I built something in the same vein, but scoped to context files.\n\n## `agent-contexts`: npm, but for `AGENTS.md`\n\nagent-contexts is a CLI. The way to think about it:\n\n> Curate agent context once in a central git repo. Install it into every\n> consumer project. Versioned, deterministic, reproducible.\n\n### How it works\n\nYou write a `contexts.yml` at the root of your contexts repo:\n\n\n\n version: \"1\"\n name: engineering-contexts\n\n mappings:\n \".\":\n context_source: ./agents/root/AGENTS.md\n description: Repo-wide conventions\n src/products:\n context_source: ./agents/products/AGENTS.md\n description: Products module\n src/common/database:\n context_source: ./agents/database/AGENTS.md\n description: Sequelize + MySQL integration\n\n\nEach mapping points a folder in the consumer project at a profile file in the contexts repo. `agent-contexts add` then:\n\n 1. Materializes the contexts repo into a git-ignored cache: `.contexts/cache/<slug>/`.\n 2. Drops **relative** symlinks at every target path. (Yes, relative - so the project still works after you move it.)\n 3. Writes a `contexts.lock` pinning each source to a commit SHA and each file to a SHA-256 hash.\n\n\n\n`agent-contexts install` is the `npm ci` of context. It only reads\n`contexts.lock`, never the manifest, so CI doesn't have to fetch the manifest or guess about upstream availability. Same lock, same files, every time.\n\n`agent-contexts status` recomputes truth from disk and exits non-zero if anything is broken, missing, or hand-edited. Easy CI gate.\n\n### Tags: different context, same folder\n\nSometimes you need a different context for the same folder, depending on what you're doing.\n\nSay your repo has a default tone — calm, professional, focused on the production codebase. But today you're refactoring and you want a more pedagogical tone with extra \"before you change this, consider…\" notes. Or you're onboarding a junior dev and you want a glossary of project-specific terms front and center.\n\nYou author those as a **tag** :\n\n\n\n mappings:\n \".\":\n context_source: ./agents/root/AGENTS.md\n src/products:\n context_source: ./agents/products/AGENTS.md\n\n tags:\n onboarding:\n mappings:\n \".\":\n context_source: ./agents/root/onboarding/AGENTS.md\n src/products:\n context_source: ./agents/products/onboarding/AGENTS.md\n refactor:\n mappings:\n src/products:\n context_source: ./agents/products/refactor/AGENTS.md\n\n\nSwitch with a flag:\n\n\n\n npx agent-contexts add your-org/your-contexts --tag onboarding\n # or\n npx agent-contexts update --tag refactor\n\n\nEffective set is `root ∪ tag` (tag wins on conflicts), so you only write the differences. The lock records which tag each entry is on, so `install` reproduces it and `update` keeps you there.\n\n### A tiny end-to-end example\n\nNestJS microservice. You want a Star-Wars-toned `AGENTS.md` for\n`src/products` — because why not.\n\n\n\n # contexts repo\n mkdir -p agents/star-wars\n\n cat > agents/products/AGENTS.md <<'EOF'\n # Products Module\n\n Follow the Repository pattern for data access.\n Split Read and Write services (CQS-lite).\n Use `class-validator` DTOs for every input.\n EOF\n\n cat > agents/star-wars/products.md <<'EOF'\n # Products Module — The Armory of the Bounty Hunters\n\n The domain heart, this is. Where artifacts of the holonet catalog,\n manage you do.\n\n - The Repository pattern, follow — data access through one gate\n - Read and Write services, split — CQS-lite, the path of clarity\n - DTOs with `class-validator`, use — `@nestjs/swagger` for the holomap\n EOF\n\n cat > contexts.yml <<'EOF'\n version: \"1\"\n mappings:\n src/products:\n context_source: ./agents/products/AGENTS.md\n description: Products module\n tags:\n star-wars:\n mappings:\n src/products:\n context_source: ./agents/star-wars/products.md\n description: Products module — Yoda edition\n EOF\n\n\nIn the consumer project:\n\n\n\n npx agent-contexts add ../your-contexts --tag star-wars --force -y\n # src/products/AGENTS.md is now a relative symlink into the cached file\n # contexts.lock records tag=star-wars + the SHA of the file\n\n npx agent-contexts status\n # ✓ src/products/AGENTS.md ok\n\n # Later, switch back to the default tone\n npx agent-contexts update # keeps the recorded tag\n npx agent-contexts add ../your-contexts -y # back to root mappings\n\n\nThat's the whole loop. Symlink in, versioned, switchable, reproducible.\n\n### A real (and less jokey) combo: code review in CI\n\nTags turn out to be the right tool for one specific scenario that I keep running into: a CI job that boots a code-review agent on every PR. You don't want that agent reading the same `AGENTS.md` files as your dev-time sessions, you want it focused, skeptical, and pointing at your review checklist, not your \"how to add a new endpoint\" doc.\n\nSo you ship a `ci-code-review` tag alongside the default one:\n\n\n\n mappings:\n \".\":\n context_source: ./agents/root/AGENTS.md\n src/products:\n context_source: ./agents/products/AGENTS.md\n\n tags:\n ci-code-review:\n mappings:\n \".\":\n context_source: ./agents/root/ci-review.md\n description: Code-review checklist + tone for CI agents\n src/products:\n context_source: ./agents/products/ci-review.md\n description: Review-time conventions for the products module\n\n\nThen the CI job does the swap before invoking the agent:\n\n\n\n # restore the lock so the cache is hot\n npx agent-contexts install\n\n # swap every entry to the CR-specific tone\n npx agent-contexts update --tag ci-code-review\n\n # boot the reviewer — it picks up AGENTS.md / CLAUDE.md / GEMINI.md\n # that all point at the ci-code-review content\n npx your-cr-agent\n\n\nSame project, same lock, completely different `AGENTS.md` content at every target. The dev never sees the CI variant; the CI never sees the dev variant. Both live in the same repo, both are versioned, and a PR against either one is just a normal git workflow.\n\n## Commands cheat sheet\n\nCommand | What it does\n---|---\n`agent-contexts add <source>` | Fetch, select mappings, link, write lock.\n`agent-contexts install` | Headless restore from `contexts.lock`. The `npm ci`.\n`agent-contexts update` | Pull upstream, diff, re-pin.\n`agent-contexts status` | Per-entry truth from disk. Exit 5 on problems.\n`agent-contexts list` | Pretty table straight from the lock.\n`agent-contexts reset` | Undo: remove links, restore `.bak` backups, delete lock + cache.\n\nAll commands take `--json`, `-y`, `--dry-run`, and `--verbose`. None of them need a TTY, so they slot into CI without fuss.\n\nThe full docs and source live at\ngithub.com/gadz82/contexts.\n\n## Pros, cons, and an honest disclaimer\n\n**Pros**\n\n * **Deterministic.** Same `contexts.lock`, same files, anywhere — laptop, CI, your colleague's machine.\n * **Versioned.** Pin to a SHA. Roll back by changing one line in the lock.\n * **Composable.** Tags mean you ship one context repo per project, not N forks of it.\n * **Familiar.** Anyone who's used `npm`, `cargo`, or `pip` already gets it.\n * **Portable.** Symlinks are relative — the project keeps working after you move or re-clone it.\n * **Cross-tool.** `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, whatever your agent of the week wants.\n * **Scriptable.** `--json` everywhere, deterministic exit codes, no TTY needed, for example you can wire it into a CI job that swaps to a `ci-cr` tag before booting the reviewer agent, then walk away.\n\n\n\n**Cons** _(fair's fair)_\n\n * **Local-path sources store an absolute path** in the lock. Commit that lock and ship it to another machine and `install` won't find anything to fetch from. The reason is in the docs (TL;DR: only a git URL is the same string everywhere). Use git for shared/CI; locals are for solo experiments.\n * **Windows without Developer Mode** falls back to file copies. It still works, but updates need a re-run.\n * **The schema is opinionated** — POSIX paths, no `..` escapes, lowercase hex hashes, that sort of thing. Read the spec once and you'll stop fighting it.\n * **This is v0.x.** I'm not promising the lockfile format won't change in a breaking way. Pin your `agent-contexts` version.\n\n\n\n## Wrapping up\n\nIf you've ever felt the pain of maintaining `AGENTS.md` files across a fleet of repos — or worse, watching them drift out of sync — give agent-contexts a try. The README is short, the install is one command, and the worst case is that you `rm` a `.contexts/` folder and a `contexts.lock`.\n\nFound a bug? Open an issue. Got a feature idea? Open a PR. Want to yell at me about the name (it should be `agent-context` and the binary should be `contexts`, I know, I know)? There's an issue tracker for that too.\n\nAnd a proper thank-you to the Vercel Skills folks. The shape of\nthis whole thing is theirs; the AGENTS-shaped twist is mine.\n\nThat's all. Go ship something.",
"title": "Agent contexts - A tool to feed you coding agents"
}