extract-spec
Skill1 starsChanged 3 months agoMITView on GitHub
Extract functional specifications FROM existing code (brownfield → spec). A read-only two-phase playbook — survey a codebase into a behavioral map, then promote a chosen capability into a CANDIDATE atomic spec in the industry-grounded template shape, routed through /foundry:intake (never a self-declared baseline). Trigger when the operator says "extract a spec from this code", "mine specs for <module>", "reverse-engineer a spec", "onboard this brownfield repo to specs", or "/foundry:extract-spec".
In this repository71 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- amendSkill
- auditSkill
- authorize-releaseSkill
- authorizeSkill
- certify-localSkill
- certify-stagingSkill
- coherence-checkSkill
- command-deckSkill
- contextSkill
- cut-releaseSkill
- dashboards-as-codeSkill
- data-tier-cutoverSkill
- decommission-gateSkill
- deploy-statusSkill
- dispatchSkill
- doctorSkill
- drift-sweepSkill
- env-hygieneSkill
- fleetSkill
- grounding-conformanceSkill
- id-applySkill
- id-architectSkill
- id-baselineSkill
- id-discoverSkill
- id-documentSkill
- id-driftSkill
- id-impactSkill
- id-implementSkill
- id-importSkill
- id-planSkill
- id-promoteSkill
- id-reviewSkill
- id-rollbackSkill
- id-simulateSkill
- id-syncSkill
- id-testSkill
- id-validateSkill
- id-verifySkill
- indexSkill
- infra-sandboxed-applySkill
- initSkill
- intakeSkill
- learn-captureSkill
- learn-distillSkill
- merge-when-greenSkill
- mode-autonomousSkill
- mode-interactiveSkill
- modeSkill
- post-upgradeSkill
- releaseSkill
- relockSkill
- report-citation-graphSkill
- reposSkill
- research-captureSkill
- research-firstSkill
- revertSkill
- sd-debugSkill
- sd-discoverSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 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.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Never invent behavior: If the code does not clearly express a contract, record it as a [NEEDS CLARIFICATION: <question>] marker — do not …
- Very specific: line 51
Do not read every file. Sample the entry surfaces first (routers/controllers/facades ≈ most of the behavior), then expand one level down …
- Distinctive: line 66
Keep it atomic — one capability-behavior per spec.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
/foundry:extract-spec
Turn existing code into functional specifications. You survey a codebase, mine the behavior it actually
enforces, and produce a candidate atomic spec — which then flows through the normal front door
(/foundry:intake → /foundry:spec-review → /foundry:authorize). You are read-heavy and write only a candidate
draft; you never authorize, merge, or baseline.
The load-bearing discipline (read first)
- Extracted ≠ authorized, and extracted ≠ desired. The code may encode bugs; a snapshot of current behavior
is a characterization, not a specification of intent. Therefore the output is an un-authorized candidate
draft that MUST be routed through
/foundry:intake(→/foundry:spec-review→/foundry:authorize). Never emit an authorized or "baseline truth" spec, and never freeze a contract from extraction. The front-authorization floor is preserved: extracted behavior becomes normative only after the operator authorizes it. - Never invent behavior. If the code does not clearly express a contract, record it as a
[NEEDS CLARIFICATION: <question>]marker — do not fabricate a requirement (Example Mapping's Question card). - Cross-validate against callers. The real contract is what callers rely on, not what a docstring claims (characterization-test discipline — capture ACTUAL, not intended, behavior; note it can pin existing bugs, so surface anything surprising as an uncertainty rather than "correcting" it).
Prior art / industry grounding
Grounded in prior-art research on the code-to-spec mechanism (how brownfield code is safely mined into a candidate spec) and on the emit shape (the template a mined capability is promoted into). Sources: Feathers, Working Effectively with Legacy Code (characterization testing); Adzic Specification by Example + Wynne's Example Mapping (flag uncertainty, don't invent); EARS/ISO-29148 (the Requirement/Invariant, measurable shape). Comparable prior art in other spec-driven tooling (e.g. spec-mining features) is one corroborating datapoint, not the source.
Phase 1 — behavioral map (read-only)
Produce a comprehension artifact; change nothing.
- Detect the stack. Find package manifests, framework configs, and entry points (routers, controllers,
service facades,
main/index/cmd). Ignore vendored/generated dirs. - Group into capabilities. Cluster entry points + their backing modules into cohesive, kebab-case capabilities by shared service/namespace. A capability is one cohesive set of behaviors.
- Operator-gated scope. Present the capability list and ask which to mine first — do NOT mine an entire monorepo at once (specs that outpace usage rot).
- Inventory the enforced behavior for the chosen capability as flat assertions, each tagged Requirement
(triggered) or Invariant (always-true), with the code-enforcement anchor (
file.method) and the domain entities. Record uncertainties inline.
Sample-and-expand (the token strategy)
Do not read every file. Sample the entry surfaces first (routers/controllers/facades ≈ most of the
behavior), then expand one level down each behavior's call chain to verify it. Stop at an external
boundary (DB/HTTP/queue), after ~3 consecutive files yield nothing new, or at a bounded file cap; defer the
unread remainder as an explicit deferred: list for a later pass.
Phase 2 — promote a capability to a candidate spec
For the operator-chosen capability, write ONE candidate feat-*.md in the industry-grounded template shape defined by the foundry context kit
(context/feat-spec-template.md, shipped in the plugin):
- Acceptance criteria as singular, measurable statements in EARS phrasing, each tagged Requirement or Invariant, with stable AC-IDs.
- A
## Prior art / industry groundingsection noting this was extracted from<source>@<commit>(so the candidate's origin + freshness are traceable), an## Out of scopeboundary, and any[NEEDS CLARIFICATION: …]markers carried forward. - Keep it atomic — one capability-behavior per spec; split a multi-capability capability.
Hand-off (compose with the shipped machinery)
The candidate is a draft, not a decision. Route it:
spec-reviewer(optional but recommended) — the independent shape/quality audit (EARS, singular, measurable, Requirement/Invariant, grounding) before intake./foundry:intake— the front door; refine the fuzzy candidate into an intake-shaped spec./foundry:spec-review→/foundry:authorize— only here does extracted behavior become normative.
You output a candidate + its behavioral map; the operator and the gates decide what becomes truth.
Contract seeding — test surfaces belong in allowed_paths
- Seed checkpoint test surfaces into
allowed_pathsat draft time. When the draft contract's checkpoints name a NEW candidate test suite (surface: test:<path>for a file the build must CREATE), seed that test path intoscope.allowed_pathsin the same draft — a contract whose own checkpoints require a file its scope forbids is internally inconsistent, andfoundry-authorizenow fails that freeze CLOSED (the surface⊆scope check). Pre-existing test files the checkpoints merely RUN need no seeding; suite KEYS (test:<key>with no/) are not paths.
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.

