Agent Spec Intent Compiler
Version: 1.0.0 | Last Updated: 2026-08-14 | Tracks: agent-spec 1.4.0
Use this skill when a user wants to move from raw PRD/issue prose to governed KLL requirements and task specs.
Routing: What You Hold, Where It Goes
Before writing anything, route the artifact. This table copies
knowledge/standards/operational/id-registry.md — the registry is the
authority, this copy is checked against it in CI.
| You hold |
Directory |
Id prefix |
Scaffold |
| A debate: should we do this, and why |
knowledge/proposals/ |
LEP- |
agent-spec knowledge new proposal LEP-NNN |
| A settled architectural ruling |
knowledge/decisions/ |
ADR- |
agent-spec knowledge new decision ADR-NNN |
| An obligation the system must satisfy |
knowledge/requirements/ |
REQ- |
agent-spec knowledge new requirement REQ-NNN |
| An executable, verifiable task contract |
specs/ |
task- |
agent-spec init --level task |
HARD GATE: when the workspace has a knowledge/requirements/ corpus, do NOT
write a task contract without satisfies: [REQ-*] — the orphan-spec lint
diagnoses the jump. "This is just a small task" and "I'll link it later" are
the rationalizations that produced orphan contracts before; route first, then
write.
Rules
- The CLI remains deterministic and model-free.
- Raw source belongs in
docs/.
- Machine-consumable truth belongs in
knowledge/requirements/*.md.
- Do not silently invent missing requirements. Emit or ask clarification questions.
- Do not treat a model inference as accepted; only human-confirmed answers may change KLL truth.
- Every generated requirement must include
## Source Trace.
- Open questions stay in
## Open Questions until answered by the human.
- For agent-spec's own development, dogfood this workflow on the repository's own KLL requirement and task spec before presenting fixtures as sufficient proof.
- Treat KLL roots as compiler trust boundaries: do not bypass unsafe-id, strict-frontmatter, kind-directory, missing-root, or symlink diagnostics.
- Read the plan as a cross-layer DAG: requirement nodes lower to work units, work units satisfy spec nodes, and spec dependencies remain explicit edges.
Workflow
- Read the raw PRD or issue.
- Draft Candidate Requirement Block entries using the PRD Intake Output Contract below.
- Ask for human confirmation before importing candidate blocks into KLL.
- Run
agent-spec requirements import --from docs/prd.md --out knowledge/requirements only after the candidate blocks are accepted.
- Run
agent-spec lint-knowledge --knowledge knowledge --gate.
- Run
agent-spec requirements plan --knowledge knowledge --specs specs --format json --gate.
- Run
agent-spec requirements test-obligations --knowledge knowledge --specs specs --format json --out .agent-spec/test_obligations.json.
- Run
agent-spec requirements worktrees --knowledge knowledge --specs specs --base main --path-prefix ../agent-spec-worktrees --out .agent-spec/worktrees.json.
- After code grounding or a change, run
agent-spec requirements affected and save the provider-neutral intent-impact report.
- Run
agent-spec requirements affected-bundle to apply the risk A/B/C evidence policy and select executable provider configs, justified checks, explicit tests, gates, guidance, and skill receipts; generated selector slugs remain non-authoritative candidates.
- After lifecycle and quality execution, run
agent-spec requirements affected-record with the same stable run_id to store the report, optional bundle, and normalized outcomes in trace ledger v2.
- When debugging, run
agent-spec requirements replay REQ-*, requirements explain-failure REQ-*, or requirements trace-graph REQ-*; all three read stored lifecycle and affected evidence only and never rerun providers, tools, skills, or models.
- Run
agent-spec requirements questions --knowledge knowledge --specs specs --format json.
- Use the Reverse Interview Loop below to ask only the emitted blocking questions, grouped by requirement id.
- Use Answer Integration below to write accepted answers back into KLL requirements as requirement clauses, scenarios, source trace entries, or resolved open questions.
- Generate task specs with
satisfies: [REQ-*].
- Run
agent-spec lifecycle, agent-spec guard, and agent-spec trace.
- For agent-spec itself, confirm dogfood evidence with
requirements replay, requirements explain-failure, and requirements trace-graph for the repository requirement id.
The skill text must preserve these exact terms for documentation tests: QA class, state-machine, reverse interview, active specs, dogfood.
PRD Intake Output Contract
Natural-language PRD intake is an AI-assisted drafting step, not a CLI parser mode. The output is a set of Candidate Requirement Block entries that a human can review and then import.
Each Candidate Requirement Block must include:
id: stable REQ-* id proposed by the agent.
title: short title from the user-facing requirement, not a filename slug.
tags: domain tags when the source text supports them.
source: original PRD, issue, ticket, or document path.
source excerpt: the smallest quoted or paraphrased source span that justifies the requirement.
confidence: high, medium, or low, based on how directly the source states the requirement.
## Problem: why the requirement exists.
## Requirements: one or more normative clauses using MUST, MUST NOT, SHOULD, or MAY.
## Scenarios: at least one executable scenario for each implementation-bearing leaf.
## Dependencies: explicit requirement ids, or None.
## Source Trace: source path plus source excerpt reference.
## Open Questions: None. only when there is no unresolved ambiguity.
Candidate blocks should use the import marker format:
<!-- agent-spec:requirement id=REQ-EXAMPLE title="Example" tags=domain source=docs/prd.md -->
## Problem
...
## Requirements
[REQ-EXAMPLE] The system MUST ...
## Scenarios
Scenario: Observable behavior
Given ...
When ...
Then ...
## Dependencies
None.
## Source Trace
- docs/prd.md#section: source excerpt ...
## Open Questions
- Should ...?
<!-- /agent-spec:requirement -->
Low-confidence blocks must keep the uncertainty in ## Open Questions; do not hide it in prose.
Reverse Interview Loop
Run requirements questions --format json after importing or editing KLL requirements. Treat the JSON as the agenda for the reverse interview.
For each blocking question:
- Show the requirement id.
- Explain which diagnostic produced the question.
- Show the exact question text.
- Include the source excerpt when available.
- Offer 2 or 3 concrete options only when the source supports them.
- Preserve a free-form answer path.
Do not ask non-blocking warning questions unless the user explicitly wants quality cleanup. Do not treat a model inference as accepted.
Reverse Interview Format
For each question, present:
- Requirement id
- Why the ambiguity blocks execution
- The exact question
- 2 or 3 concrete answer choices when the source text supports them
- A free-form option when none of the choices is correct
Never treat an inferred answer as accepted unless the human confirms it.
Answer Integration
After the human answers:
- Mark the answer as human-confirmed in the working notes or source trace.
- Convert the answer into a concrete requirement clause, scenario step, dependency, QA class, or source trace entry.
- Remove or rewrite the corresponding
## Open Questions item only after the answer is represented in the requirement body.
- Re-run
lint-knowledge --gate, requirements plan --gate, and requirements questions.
- If questions remain blocking, continue the loop before generating task specs.
1---2name: agent-spec-intent-compiler3description: Use when converting PRD or issue prose into KLL requirements, running the intent compiler plan, or reverse-interviewing a human to resolve requirement ambiguity before task spec generation.4---56# Agent Spec Intent Compiler78> **Version:** 1.0.0 | **Last Updated:** 2026-08-14 | **Tracks:** agent-spec 1.4.0910Use this skill when a user wants to move from raw PRD/issue prose to governed KLL requirements and task specs.1112## Routing: What You Hold, Where It Goes1314Before writing anything, route the artifact. This table copies15`knowledge/standards/operational/id-registry.md` — the registry is the16authority, this copy is checked against it in CI.1718| You hold | Directory | Id prefix | Scaffold |19|---|---|---|---|20| A debate: should we do this, and why | `knowledge/proposals/` | `LEP-` | `agent-spec knowledge new proposal LEP-NNN` |21| A settled architectural ruling | `knowledge/decisions/` | `ADR-` | `agent-spec knowledge new decision ADR-NNN` |22| An obligation the system must satisfy | `knowledge/requirements/` | `REQ-` | `agent-spec knowledge new requirement REQ-NNN` |23| An executable, verifiable task contract | `specs/` | `task-` | `agent-spec init --level task` |2425HARD GATE: when the workspace has a `knowledge/requirements/` corpus, do NOT26write a task contract without `satisfies: [REQ-*]` — the orphan-spec lint27diagnoses the jump. "This is just a small task" and "I'll link it later" are28the rationalizations that produced orphan contracts before; route first, then29write.3031## Rules3233- The CLI remains deterministic and model-free.34- Raw source belongs in `docs/`.35- Machine-consumable truth belongs in `knowledge/requirements/*.md`.36- Do not silently invent missing requirements. Emit or ask clarification questions.37- Do not treat a model inference as accepted; only human-confirmed answers may change KLL truth.38- Every generated requirement must include `## Source Trace`.39- Open questions stay in `## Open Questions` until answered by the human.40- For agent-spec's own development, dogfood this workflow on the repository's own KLL requirement and task spec before presenting fixtures as sufficient proof.41- Treat KLL roots as compiler trust boundaries: do not bypass unsafe-id, strict-frontmatter, kind-directory, missing-root, or symlink diagnostics.42- Read the plan as a cross-layer DAG: requirement nodes lower to work units, work units satisfy spec nodes, and spec dependencies remain explicit edges.4344## Workflow45461. Read the raw PRD or issue.472. Draft Candidate Requirement Block entries using the PRD Intake Output Contract below.483. Ask for human confirmation before importing candidate blocks into KLL.494. Run `agent-spec requirements import --from docs/prd.md --out knowledge/requirements` only after the candidate blocks are accepted.505. Run `agent-spec lint-knowledge --knowledge knowledge --gate`.516. Run `agent-spec requirements plan --knowledge knowledge --specs specs --format json --gate`.527. Run `agent-spec requirements test-obligations --knowledge knowledge --specs specs --format json --out .agent-spec/test_obligations.json`.538. Run `agent-spec requirements worktrees --knowledge knowledge --specs specs --base main --path-prefix ../agent-spec-worktrees --out .agent-spec/worktrees.json`.549. After code grounding or a change, run `agent-spec requirements affected` and save the provider-neutral intent-impact report.5510. Run `agent-spec requirements affected-bundle` to apply the risk A/B/C evidence policy and select executable provider configs, justified checks, explicit tests, gates, guidance, and skill receipts; generated selector slugs remain non-authoritative candidates.5611. After lifecycle and quality execution, run `agent-spec requirements affected-record` with the same stable `run_id` to store the report, optional bundle, and normalized outcomes in trace ledger v2.5712. When debugging, run `agent-spec requirements replay REQ-*`, `requirements explain-failure REQ-*`, or `requirements trace-graph REQ-*`; all three read stored lifecycle and affected evidence only and never rerun providers, tools, skills, or models.5813. Run `agent-spec requirements questions --knowledge knowledge --specs specs --format json`.5914. Use the Reverse Interview Loop below to ask only the emitted blocking questions, grouped by requirement id.6015. Use Answer Integration below to write accepted answers back into KLL requirements as requirement clauses, scenarios, source trace entries, or resolved open questions.6116. Generate task specs with `satisfies: [REQ-*]`.6217. Run `agent-spec lifecycle`, `agent-spec guard`, and `agent-spec trace`.6318. For agent-spec itself, confirm dogfood evidence with `requirements replay`, `requirements explain-failure`, and `requirements trace-graph` for the repository requirement id.6465The skill text must preserve these exact terms for documentation tests: QA class, state-machine, reverse interview, active specs, dogfood.6667## PRD Intake Output Contract6869Natural-language PRD intake is an AI-assisted drafting step, not a CLI parser mode. The output is a set of Candidate Requirement Block entries that a human can review and then import.7071Each Candidate Requirement Block must include:7273- `id`: stable `REQ-*` id proposed by the agent.74- `title`: short title from the user-facing requirement, not a filename slug.75- `tags`: domain tags when the source text supports them.76- `source`: original PRD, issue, ticket, or document path.77- `source excerpt`: the smallest quoted or paraphrased source span that justifies the requirement.78- `confidence`: `high`, `medium`, or `low`, based on how directly the source states the requirement.79- `## Problem`: why the requirement exists.80- `## Requirements`: one or more normative clauses using MUST, MUST NOT, SHOULD, or MAY.81- `## Scenarios`: at least one executable scenario for each implementation-bearing leaf.82- `## Dependencies`: explicit requirement ids, or `None.`83- `## Source Trace`: source path plus source excerpt reference.84- `## Open Questions`: `None.` only when there is no unresolved ambiguity.8586Candidate blocks should use the import marker format:8788```md89<!-- agent-spec:requirement id=REQ-EXAMPLE title="Example" tags=domain source=docs/prd.md -->90## Problem9192...9394## Requirements9596[REQ-EXAMPLE] The system MUST ...9798## Scenarios99100Scenario: Observable behavior101 Given ...102 When ...103 Then ...104105## Dependencies106107None.108109## Source Trace110111- docs/prd.md#section: source excerpt ...112113## Open Questions114115- Should ...?116<!-- /agent-spec:requirement -->117```118119Low-confidence blocks must keep the uncertainty in `## Open Questions`; do not hide it in prose.120121## Reverse Interview Loop122123Run `requirements questions --format json` after importing or editing KLL requirements. Treat the JSON as the agenda for the reverse interview.124125For each blocking question:126127- Show the requirement id.128- Explain which diagnostic produced the question.129- Show the exact question text.130- Include the source excerpt when available.131- Offer 2 or 3 concrete options only when the source supports them.132- Preserve a free-form answer path.133134Do not ask non-blocking warning questions unless the user explicitly wants quality cleanup. Do not treat a model inference as accepted.135136## Reverse Interview Format137138For each question, present:139140- Requirement id141- Why the ambiguity blocks execution142- The exact question143- 2 or 3 concrete answer choices when the source text supports them144- A free-form option when none of the choices is correct145146Never treat an inferred answer as accepted unless the human confirms it.147148## Answer Integration149150After the human answers:151152- Mark the answer as human-confirmed in the working notes or source trace.153- Convert the answer into a concrete requirement clause, scenario step, dependency, QA class, or source trace entry.154- Remove or rewrite the corresponding `## Open Questions` item only after the answer is represented in the requirement body.155- Re-run `lint-knowledge --gate`, `requirements plan --gate`, and `requirements questions`.156- If questions remain blocking, continue the loop before generating task specs.