{
  "markdown": "<div align=\"center\">\n\n# Capsule\n\n**Compact, source-linked context packs for coding agents.**\n\n<img src=\"docs/demo.gif\" width=\"740\" alt=\"capsule init and estimate demo\"/>\n\n<br/>\n\n[![npm](https://img.shields.io/npm/v/capsulectx?color=000&labelColor=111&label=npm&style=flat-square)](https://www.npmjs.com/package/capsulectx)\n[![license](https://img.shields.io/github/license/dawitlabs/capsule?color=000&labelColor=111&style=flat-square)](LICENSE)\n[![node](https://img.shields.io/node/v/capsulectx?color=000&labelColor=111&style=flat-square)](package.json)\n[![ci](https://img.shields.io/github/actions/workflow/status/dawitlabs/capsule/ci.yml?color=000&labelColor=111&label=ci&style=flat-square)](https://github.com/dawitlabs/capsule/actions)\n\n[Docs](https://capsulectx.vercel.app) · [Quickstart](https://capsulectx.vercel.app/guide/quickstart) · [Commands](https://capsulectx.vercel.app/reference/commands)\n\n</div>\n\n---\n\nMCP gives agents tools. Skills give agents procedures. Capsules give agents compact project context.\n\nLarge repositories make coding agents burn tokens rediscovering the same files, decisions, conventions, and setup details over and over. Capsule targets a **50–70% reduction in repeated repository-discovery context** for large, multi-session agent work.\n\n## Install\n\n**No install required — run directly with npx (always gets the latest version):**\n\n```bash\nnpx capsulectx init\n```\n\n**Or install globally with your package manager:**\n\n```bash\n# npm\nnpm install -g capsulectx\n\n# pnpm\npnpm add -g capsulectx\n\n# yarn\nyarn global add capsulectx\n\n# bun\nbun add -g capsulectx\n```\n\n**Keep it up to date:**\n\n```bash\nnpm install -g capsulectx --prefer-online\n```\n\n> **Tip:** `npx` is the easiest option — it always runs the latest published version with no manual update step.\n\n## Quickstart\n\n```bash\nnpx capsulectx init\n```\n\nCapsule scans your repo, optionally enriches capsules with AI (using your installed Claude CLI, API keys, or a generated prompt for any browser-based AI), and creates:\n\n```\n.capsules/\n  index.md\n  architecture.md\n  setup.md\n  api.md\n  data.md\n  ui.md\n  testing.md\n  deployment.md\n```\n\nEach capsule is a Markdown file with source fingerprints in JSON frontmatter:\n\n```md\n---json\n{\n  \"name\": \"api\",\n  \"sources\": [\"src/api/**\"],\n  \"fingerprints\": { \"src/api/users.ts\": \"sha256:...\" },\n  \"updated_at\": \"2026-06-20T14:00:00.000Z\"\n}\n---\n\n# API Capsule\n\n## Purpose\n\nRequest handlers, routes, controllers, and service boundaries.\n\n## Key Files\n\n- `src/api/users.ts`: source file matched by this capsule.\n\n## Decisions\n\n- Record stable decisions here so future agents do not rediscover them.\n```\n\nAgents read `.capsules/index.md`, choose the relevant capsule, check staleness, then inspect only the source files that actually matter.\n\n## Commands\n\n| Command | What it does |\n|---|---|\n| `capsule init` | Scan repo, run AI enrichment (optional), write all capsules |\n| `capsule enrich` | Re-run AI enrichment on existing capsules |\n| `capsule apply` | Apply AI-generated JSON to capsule Conventions and Decisions |\n| `capsule write <name>` | Refresh one capsule from source (preserves your edits) |\n| `capsule refresh <name>` | Explicitly refresh one capsule |\n| `capsule refresh --all` | Explicitly refresh all detected capsules |\n| `capsule get <name>` | Print one capsule to stdout |\n| `capsule scan` | Print detected source groups without writing |\n| `capsule stale [name]` | Check which source files changed since last write |\n| `capsule estimate <name>` | Show estimated token savings for one capsule |\n| `capsule stats` | Show token savings across all capsules |\n| `capsule report [name]` | Show reproducible source/capsule/stale token savings |\n| `capsule report --write` | Write `.capsules/report.md` as a proof artifact |\n| `capsule check` | CI-friendly freshness/config check; exits nonzero on stale or missing capsules |\n| `capsule --mcp` | Start MCP server for native agent integration |\n\n## MCP Server\n\nCapsule ships an MCP server so Claude Code and other MCP-compatible agents can natively discover and consume capsules — no manual file reads needed.\n\n**Add to your project's `.claude/settings.json`:**\n\n```json\n{\n  \"mcpServers\": {\n    \"capsule\": {\n      \"command\": \"npx\",\n      \"args\": [\"capsulectx\", \"--mcp\"]\n    }\n  }\n}\n```\n\n**Or globally in `~/.claude/settings.json`** to enable for all projects.\n\nOnce configured, agents get these tools automatically:\n\n| Tool | What it does |\n|---|---|\n| `capsule_list` | List all capsules with freshness status |\n| `capsule_get` | Read a capsule's compressed context; warns when stale but does not write |\n| `capsule_refresh` | Explicitly refresh one capsule or all capsules |\n| `capsule_stale` | Check which capsules have outdated sources |\n| `capsule_stats` | Show token savings per capsule |\n| `capsule_report` | Show machine-readable discovery-savings proof |\n| `capsule_check` | CI-style stale/missing/config check |\n| `capsule_init` | Generate capsules for the current repo |\n\nCapsules are also available as MCP resources at `capsule:///index` and `capsule:///{name}`.\n\n## Seeing the savings\n\n```\n$ capsule report architecture\n\nCapsule: architecture\n\n  capsule       status     source   capsule     stale   saved\n  architecture  fresh       9,607       417         0     96%\n```\n\nToken counts use the cl100k_base tokenizer for accurate measurement.\n\nFor CI, run:\n\n```bash\nnpx capsulectx check\n```\n\nIt exits nonzero when capsules are stale, missing, or blocked by invalid config.\n\n## Agent Workflow\n\nAdd this to `AGENTS.md`, `CLAUDE.md`, Cursor rules, or your agent instructions:\n\n```md\nBefore working in this repo:\n\n1. Read `.capsules/index.md` if it exists.\n2. Read the capsule matching the task area.\n3. Run `capsule stale <name>` when the CLI is available.\n4. If stale, inspect changed source files before editing.\n5. Update capsules when durable project knowledge changes.\n```\n\nWorks with any agent that can read files — Claude Code, Codex, Cursor, Windsurf, Devin, custom MCP agents.\n\n## Custom Groups\n\nCapsule detects standard layouts out of the box. For non-standard structure, add `.capsules/config.json`:\n\n```json\n{\n  \"groups\": [\n    {\n      \"name\": \"workers\",\n      \"description\": \"Background jobs, queues, and scheduled tasks.\",\n      \"sources\": [\"src/workers/**\", \"src/jobs/**\"]\n    }\n  ],\n  \"ignore\": [\"legacy/**\"]\n}\n```\n\nA `groups` entry with the same `name` as a default group overrides it. New names are appended. `ignore` patterns extend the default ignore list.\n\nSee [`docs/capsule-format.md`](docs/capsule-format.md) for the public capsule file format.\n\n## Building the Demo\n\nThe animation in this README is a generated GIF — no screen-recording tools required.\n\n```bash\nnpm run demo\n```\n\nRequires `rsvg-convert` (`librsvg` / `librsvg2-tools`) and `ffmpeg`. The script outputs `docs/demo.gif` from SVG frames rendered at 2× for retina. See [`scripts/build-demo.mjs`](scripts/build-demo.mjs).\n\n## Documentation Site\n\nThe OSS docs live in `docs-site/` and are built with VitePress.\n\n```bash\nnpm run docs:dev\nnpm run docs:build\n```\n\n## Status\n\nCapsule is early but functional. Current capabilities:\n\n- Language-agnostic repo scanning with monorepo support (Turborepo, pnpm workspaces)\n- Static analysis: framework detection, table/model extraction, route detection, env vars\n- AI enrichment on init — launches your installed Claude CLI, calls Claude/OpenAI API, or generates a prompt for any browser-based AI (Claude.ai, ChatGPT, Cursor, Windsurf)\n- Write-safe re-generation: human edits to Conventions and Decisions are preserved on refresh\n- MCP server for native Claude Code / agent integration\n- Real token counting (cl100k_base) with savings dashboard\n- TypeScript API surface extraction\n- Binary file filtering\n- Stale detection and token savings estimation\n- Reproducible `report` and CI-friendly `check`\n- Custom group config via `.capsules/config.json`\n- Auto-patches `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, `.windsurfrules` with capsule instructions\n\n**Roadmap:**\n- smarter `write` that diffs source changes and suggests targeted updates\n- before/after token reports for real agent sessions\n- GitHub Action wrapper for `capsule check`\n\n## Install for Local Development\n\n```bash\ngit clone https://github.com/dawitlabs/capsule.git\ncd capsule\nnpm install\nnpm run build\nnode dist/cli.js init\n```\n\n## License\n\nMIT\n",
  "bytes": 8326,
  "sha": "8811698e3ae11496b62644caf05bfcfc18977724ba0debf2aa3f3a0d98d531e8",
  "repo_slug": "dawitlabs/capsule",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_dawitlabs_capsule_a5885c3b/readme"
}