You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MCP-capable coding agents pay a fixed "cold-boot tax" every time they open a Charter-governed repo. A typical discovery sequence looks like:
ls, git log --oneline, git status
Read CLAUDE.md / README.md / top-level docs
grep for route handlers to understand the HTTP surface
Read package.json, wrangler.toml, tsconfig.json
Walk the import graph to identify load-bearing files
Re-derive module boundaries, sensitivity tags, and governance posture
In practice that's 15–30 tool calls and 10k–50k tokens of discovery before the agent produces anything useful — repeated across every session, every agent, every invocation.
Charter already emits most of the information an agent needs, via separate commands:
charter surface — routes, D1 schema, exported APIs
charter blast --summary — top hot files, cross-cutting warnings
.charter/config.json — repo identity (stack, preset) and sensitivity tags
charter adf populate — governance context (ADF module manifest)
The gap is that these are siloed — there's no single artifact an agent reads as its first action.
Proposal
Add charter context (CLI) and charter_brief (MCP tool) that compose surface, blast, config-file reads, and the ADF module manifest into a single pre-digested markdown brief.
Concrete moves
charter context command in @stackbilt/cli — composes primitives in memory, emits markdown brief to stdout. Generators live alongside existing command adapters (no new package).
On-disk mirror at .charter/context.md — same directory as existing generated artifacts like data-registry.yaml. Regenerated by post-commit hook; never hand-authored; .gitignored by charter init / charter bootstrap.
charter_brief MCP tool in charter serve — re-runs extractions live (no on-disk dependency, always fresh). Name chosen to avoid collision with existing getProjectContext (which returns the full merged ADF bundle — different concept).
Per-project-type canonical seed strategy for blast — derived from .charter/config.jsonstack/preset. Worker → routes + src/index.*; CLI → bin entries + command files; library → exported entry points.
Brief shape (sketch)
# <reponame> — repo brief (generated)## Identity
<.charter/config.json: stack, preset; package.json: name, description, bin entries>
## Surface
<surface: N routes, M D1 tables, top 5 endpoints with methods>
## Hotspots
<blast: top 10 hot files, each with importers count, CROSS_CUTTING flag>
## Sensitivity
<.charter/config.json sensitivity tags: file pattern → class>
## Governance
<ADF module manifest: which modules are present, one-line descriptions>
## Generated
<git SHA, UTC timestamp>
Prerequisite
refactor(surface,cli): Zod-Core-Out vertical slice for surface #114 — refactor(surface,cli): Zod-Core-Out vertical slice for surface. The brief's Surface section is only as stable as surface's output shape. Consuming un-Core-Out'd surface output in the brief would cause the brief to reshape with each future refactor.
Blast Core-Out shipped in 0.11.0 (#110). classify is not a prerequisite — it's a change classifier (SURFACE/LOCAL/CROSS_CUTTING for commit descriptions), not a repo-identity primitive. Repo identity comes from .charter/config.json + package.json, which are already stable JSON formats.
Acceptance criteria
charter context prints a single pre-digested markdown brief to stdout.
Per-project-type seed strategy for blast documented in charter context --help, keyed off .charter/config.json.
On-disk mirror at .charter/context.md; .gitignore updated automatically in charter init / charter bootstrap.
Post-commit hook recipe documented in CLI README.
charter serve registers charter_brief; tool handler re-runs primitives live (no stale-cache serving).
Brief size ≤2000 tokens for a repo with ≤300 source files.
CI enforcement: scripts/measure-brief-size.ts runs in CI and fails the workflow if Charter's self-generated brief exceeds the size threshold. Blocking, not advisory.
Measurable win: a fresh agent session can reach first useful action in ≤5 tool calls (brief read + targeted follow-ups), down from 15–30 a cold agent currently performs.
Non-goals
Auto-generating ADF modules (reverted per review). Writing to .ai/ collides with human-authored governance content. The brief is a separate artifact at .charter/context.md.
Cross-repo introduction — "manifests other repos consume programmatically." Separate post-1.0 RFC.
Replacing CLAUDE.md — stays authoritative for repo-specific rules; brief is a generated summary alongside.
Rewriting ADF — plumbing, not a new subsystem.
New package — generators live in @stackbilt/cli alongside existing command adapters (blast.ts, surface.ts). No @stackbilt/primitives layer.
Risks / tradeoffs
Bloat. Hard size ceiling enforced in charter context (truncation fallback with warning) and CI (hard fail). --verbose escape hatch for interactive human use.
Staleness. MCP tool always re-runs live (cheap — primitives are fast). On-disk mirror is for humans/CI only and regenerates via post-commit hook. No SHA-diffing staleness fallback.
Context
MCP-capable coding agents pay a fixed "cold-boot tax" every time they open a Charter-governed repo. A typical discovery sequence looks like:
ls,git log --oneline,git statusCLAUDE.md/README.md/ top-level docsgrepfor route handlers to understand the HTTP surfacepackage.json,wrangler.toml,tsconfig.jsonIn practice that's 15–30 tool calls and 10k–50k tokens of discovery before the agent produces anything useful — repeated across every session, every agent, every invocation.
Charter already emits most of the information an agent needs, via separate commands:
charter surface— routes, D1 schema, exported APIscharter blast --summary— top hot files, cross-cutting warnings.charter/config.json— repo identity (stack, preset) and sensitivity tagscharter adf populate— governance context (ADF module manifest)The gap is that these are siloed — there's no single artifact an agent reads as its first action.
Proposal
Add
charter context(CLI) andcharter_brief(MCP tool) that composesurface,blast, config-file reads, and the ADF module manifest into a single pre-digested markdown brief.Concrete moves
charter contextcommand in@stackbilt/cli— composes primitives in memory, emits markdown brief to stdout. Generators live alongside existing command adapters (no new package)..charter/context.md— same directory as existing generated artifacts likedata-registry.yaml. Regenerated by post-commit hook; never hand-authored;.gitignored bycharter init/charter bootstrap.charter_briefMCP tool incharter serve— re-runs extractions live (no on-disk dependency, always fresh). Name chosen to avoid collision with existinggetProjectContext(which returns the full merged ADF bundle — different concept)..charter/config.jsonstack/preset. Worker → routes +src/index.*; CLI →binentries + command files; library → exported entry points.Brief shape (sketch)
Prerequisite
surface's output shape. Consuming un-Core-Out'd surface output in the brief would cause the brief to reshape with each future refactor.Blast Core-Out shipped in 0.11.0 (#110).
classifyis not a prerequisite — it's a change classifier (SURFACE/LOCAL/CROSS_CUTTING for commit descriptions), not a repo-identity primitive. Repo identity comes from.charter/config.json+package.json, which are already stable JSON formats.Acceptance criteria
charter contextprints a single pre-digested markdown brief to stdout.surface+blastoutputs (post-prereq refactor(surface,cli): Zod-Core-Out vertical slice for surface #114).charter context --help, keyed off.charter/config.json..charter/context.md;.gitignoreupdated automatically incharter init/charter bootstrap.charter serveregisterscharter_brief; tool handler re-runs primitives live (no stale-cache serving).scripts/measure-brief-size.tsruns in CI and fails the workflow if Charter's self-generated brief exceeds the size threshold. Blocking, not advisory.Non-goals
.ai/collides with human-authored governance content. The brief is a separate artifact at.charter/context.md.@stackbilt/clialongside existing command adapters (blast.ts,surface.ts). No@stackbilt/primitiveslayer.Risks / tradeoffs
charter context(truncation fallback with warning) and CI (hard fail).--verboseescape hatch for interactive human use.Sequencing
charter context+charter_briefMCP tool in@stackbilt/cli.charter init/charter bootstrapto add.charter/context.mdto.gitignore.scripts/measure-brief-size.tsinto CI.Related
@stackbilt/cligovernance surface; no gateway dep)