npx skills add ...
npx skills add trkbt10/indexion-skills --skill indexion-sdd
Generate SDD requirements from RFCs/specs and quantitatively verify implementation conformance. spec draft → spec align → spec verify → automated validation loop with codex/claude. Operate spec-to-impl drift gates as CI checks.
npx skills add trkbt10/indexion-skills --skill indexion-sdd
Bridge indexion's quantitative spec alignment tools with SDD agent workflows (cc-sdd, codex, etc.).
Provides: RFC/document → SDD draft, spec↔impl drift detection, and a validation loop that feeds indexion's quantitative results into agent-driven qualitative review.
codex spec-impl completes, to check for drift before merging--lang to match the implementation language, not the
spec language. If code is in English, use --lang en. Mismatched
languages break spec align diff vocabulary matching.Verify indexion is available before proceeding. The drift gate (Step 2.5) and validation loop (Step 3) depend on it:
If indexion is not installed, install it first. If the KGF for your
spec format is not recognized, update indexion to a version that
includes it. See Step 2.7 for the fallback when this cannot be resolved.
Fetch the specification document (RFC, ISO standard, etc.) and prepare it:
The output uses ### Requirement N: and #### N.M: hierarchy matching
cc-sdd's expected ID format. The agent's $kiro-spec-requirements phase will
further refine into EARS format with acceptance criteria.
Supported specification formats:
| Format | Extension | KGF spec |
|---|---|---|
| RFC plaintext | .rfc.txt | rfc-plaintext |
| ISO/IEC technical document | .spec.txt | technical-document |
| Markdown (README, etc.) | .md | markdown |
After writing requirements, verify they cover the source specification:
Traceability chain: spec align works between documents at the
same abstraction level. For full traceability, check each adjacent pair:
Do NOT align source spec directly against design or code — the vocabulary spaces differ too much (normative spec language vs. software design vs. code identifiers). Each hop bridges one abstraction gap.
Semantic fidelity review (not automatable):
spec align checks vocabulary overlap, but cannot detect requirements
that invert the source spec's intent while using the same vocabulary.
A common failure mode:
Both mention "DCTDecode", "filter", "shall" — vocabulary matches, so
spec align reports MATCHED. But the requirement says the opposite of
what the spec demands. This creates a hidden gap that only surfaces when
E2E tests fail (Step 2.9).
After spec draft generates requirements, review for these patterns:
"not yet supported", "not implemented", "placeholder", "stub"
— these indicate the draft punted on a spec requirement"shall return an error" for something the source spec says "shall decode/process/convert" — intent inversionFix these before proceeding to Step 2. Leaving them creates a false sense of spec conformance that only E2E testing can expose.
cc-sdd v3+ uses skills mode ($kiro-spec-* commands).
Non-interactive execution with indexion gates between phases:
If DRIFTED items remain for the requirement your task addresses, fix them (add spec vocabulary to public declaration doc comments) and re-commit.
When all tasks are done, spec align status --fail-on drifted must exit 0.
Commit your work after completing tasks. Do not leave changes uncommitted. PHASE_A_EOF
sed -i '' "s//$FEATURE/g; s//$PKG/g" $REPORT_DIR/impl-phase-a.md
codex exec --full-auto --json -C .
"$(cat $REPORT_DIR/impl-phase-a.md)" > $REPORT_DIR/impl-phase-a.jsonl
indexion spec align status $SPEC_DIR/requirements.md src/$PKG/
--threshold 0.3 --fail-on drifted
git add . && git commit -m "impl: Phase A types for $FEATURE"
cat > $REPORT_DIR/impl-phase-b.md << 'PHASE_B_EOF'
You are implementing Phase B (Logic & Algorithms) of the feature.
Phase A (type definitions) is already committed. Read the existing type
definitions in src/<pkg>/ and the design in .kiro/specs/<FEATURE>/design.md.
In this phase, implement:
Every requirement that describes processing, conversion, interpretation, or validation MUST have a corresponding function implementation — not just a type definition.
SHALLOW is detected when a requirement matches a type definition in a file that has no non-trivial function implementations (>4 lines). To resolve:
Add functions to the SAME FILE where the type is defined.
Do NOT put logic in a separate file — SHALLOW checks per-file. If a type is defined in one file and its methods are in a different file, the type's file still has no functions and triggers SHALLOW.
Examples of functions that resolve SHALLOW:
Examples that do NOT resolve SHALLOW (too trivial, ≤4 lines):
After completing each task and committing, run:
The --fail-on any gate includes SHALLOW detection: if a requirement
matched only to type definitions with no function implementations in
the same file, it is flagged as SHALLOW. You must add function
implementations to resolve SHALLOW items.
If DRIFTED, SPEC_ONLY, or SHALLOW items remain, fix them before proceeding.
When all tasks are done, spec align status --fail-on any must exit 0
with Shallow: 0.
Commit your work after completing tasks. Do not leave changes uncommitted. PHASE_B_EOF
sed -i '' "s//$FEATURE/g; s//$PKG/g" $REPORT_DIR/impl-phase-b.md
codex exec --full-auto --json -C .
"$(cat $REPORT_DIR/impl-phase-b.md)" > $REPORT_DIR/impl-phase-b.jsonl &
CODEX_PID=$!
Operational notes:
--json with file redirect + tail -f. Piping through
| tail suppresses all output until completion.$(cat file.md). Shell
HEREDOC with $() can cause stdin blocking./loop (Claude Code) to poll git log --oneline -1 + ps
every 60-120s during long impl runs.After each $kiro-impl task commit, run spec alignment to verify the
task closed its corresponding requirement gap. Do NOT proceed to the
next task if the requirement addressed by the current task is still
DRIFTED, SPEC_ONLY, or SHALLOW.
Phase A gate (types only — SHALLOW is expected and tolerated):
Phase B gate (logic — SHALLOW must be zero):
SHALLOW detection: When a requirement matches only to type/struct/enum
declarations in a file that contains no non-trivial function implementations
(>4 lines), spec align classifies it as SHALLOW. This catches two patterns:
Resolution: Add methods to the same file where the type is defined. Trivial functions (constructors, one-liner accessors ≤4 lines) do not count. See Phase B prompt template for examples.
When including this gate in a Codex prompt, instruct the agent to run these commands after each task commit and fix any flagged items before proceeding. Example instruction block for the prompt:
Phase B rarely resolves all SHALLOW items in a single Codex session. Common causes:
Iteration protocol:
After each Phase B session completes:
Run the SHALLOW audit:
If Shallow: 0, proceed to E2E verification (Step 2.9).
If SHALLOW > 0, identify the specific items:
Write a targeted round prompt that:
Launch the next round:
Typical: 2-3 rounds. Round 1 adds core logic, Round 2 forces same-file methods, Round 3 catches remaining edge cases.
Codex processes can stall (lost API connection, blocked review loop, etc.). This is common during long Phase B sessions.
Detection:
Recovery — never commit manually:
When a stall is confirmed:
kill $CODEX_PIDgit log, git status, git diff --cachedcodex exec --full-auto --json -C . "$(cat $REPORT_DIR/resume-prompt.md)" > $REPORT_DIR/impl-resume.jsonl &Never commit implementation code manually. All commits must come from the Codex agent. If you commit manually, you bypass the SDD protocol (RED→GREEN evidence, review, verification) and invalidate the workflow.
Codex runs indexion commands inside the impl project directory. If
indexion is not installed, is too old, or lacks required KGF specs,
the drift gate commands will fail or timeout inside Codex.
Prevention (recommended): Verify in Step 0 that indexion works in
the project directory before starting the SDD run:
If indexion is not available or broken, install or update it first.
Fallback — orchestrator-side drift gate:
If indexion cannot be fixed before the run (e.g., a required KGF spec
is not yet released), the orchestrator runs the drift gate externally:
--specs-dir caveat: When running the indexion binary directly
(not via the project's build tool), it may not find KGF specs
automatically. Pass --specs-dir explicitly:
Without this, spec align may return "No alignment data found" because
the requirement document format is unrecognized.
After all SHALLOW items are resolved (Shallow: 0), verify that the
implementation actually works end-to-end. spec align only checks
vocabulary — it cannot confirm functional correctness.
Write E2E tests that exercise the full pipeline against real input data:
Common E2E failure modes after SHALLOW=0:
If E2E tests fail, write additional Codex prompts targeting the specific failure. The spec align gate ensures the vocabulary stays aligned while Codex fixes the implementation.
Multiple features can run in parallel Codex sessions:
Caveats:
src/graphics/). Git will auto-merge unless the
same lines are modified./loop — check event counts, commits,
and process vitals for each PID.This is where indexion adds value beyond pure agent review.
The validation script:
spec verify (vocabulary gap between spec and impl)spec align diff (requirement-level drift)spec align trace (traceability matrix)spec align status (CI-style pass/fail)validate-impl prompt--fix, automatically re-runs spec-impl for failing tasksAfter $kiro-validate-impl passes but spec align shows DRIFTED/SPEC_ONLY,
the implementation is functionally correct but lacks spec vocabulary in doc
comments. This step closes that gap.
Note: $kiro-validate-impl (cc-sdd) does not invoke indexion's spec align
internally. This step bridges the two tools.
Key constraints:
spec align.open function documents the full flow).Known blind spots:
CLI entry points with no public API: Main/entry-point modules
often have no public declarations — all functions are private to the
module. spec align extracts vocabulary only from public declarations,
so entry-point modules always show Matched: 0 / SPEC_ONLY for all
requirements. Workaround: split CLI logic into a library module
that exposes public functions, with the entry point as a thin
dispatcher. Align requirements against the library, not the entry point.
Empty doc comments: Codex often writes doc comment syntax without
any actual text content. These are invisible to spec align because
they contain no vocabulary. The vocab fix prompt must explicitly
instruct the agent: "Do not leave doc comments empty. Every public
declaration must have a doc comment that describes its purpose using
terminology from the requirements."
Internal-only modules (private functions): When implementation
logic is entirely private (not public), spec align cannot see it.
This is common in filter/codec packages where a public pipeline
function dispatches to private decoders. SHALLOW triggers on the
type file even though logic exists. Workaround: either promote
key internal functions to public (they become testable API surface),
or consolidate spec vocabulary into the public pipeline function's
doc comment so the requirement matches there instead.
Literal requirements vs. identifier matching: Requirements that reference project-specific literals (package names, table numbers, configuration keys) will show as DRIFTED if the implementation doc comments don't mention the exact literal. This is usually a sign that the requirements contain project-specific details that don't belong there — fix the requirements to use generic descriptions, or accept that the vocab fix agent must propagate these literals.
"Fallback" framing vs. spec-mandated implementation: When the agent proposes a "fallback" for an unsupported feature, verify whether the feature is actually required by the source specification. Example: TrueType font cmap table parsing was proposed as a "fallback" but is in fact mandated by the spec for TrueType font encoding resolution. Framing spec requirements as fallbacks creates incorrect priority and may lead to incomplete implementation.
Vocabulary match ≠ functional correctness: DRIFTED=0 and SHALLOW=0 confirm vocabulary alignment but cannot verify that the implementation actually works. E2E tests (text extraction from real files, visual rendering comparison) are essential to catch:
After implementation, use plan reconcile to detect drift between
implementation code and its documentation (README, doc comments, etc.):
plan reconcile complements spec align in the SDD workflow:
Use spec align for pre-merge gates (CI). Use plan reconcile for
ongoing documentation maintenance after the feature ships.
For projects that produce visual output (PDF rendering, SVG export, image processing), vocabulary-based spec align is insufficient. Add pixel-level comparison against reference renderings.
Pipeline:
pdf svg input.pdf output.svg)rsvg-convert, puppeteer, etc.)pdftoppm, etc.)pixelmatch — report diff percentageThresholds:
Iterative improvement: Visual precision requires multiple rounds. Each round fixes one category (font mapping → glyph positioning → image CTM → colour conversion). Track all PDFs per round to catch regressions — fixing one PDF must not break another.
Known limitations of visual diff:
| Option | Default | Description |
|---|---|---|
--output, -o | stdout | Output file path |
--format | markdown | Output format: markdown, json |
--profile | sdd-requirement | Draft profile (KGF spec name) |
--max-requirements | 64 | Maximum requirements to extract |
--specs-dir | auto | KGF specs directory |
| Option | Default | Description |
|---|---|---|
--spec | (required) | Spec document glob (repeatable) |
--format | json | Output format: json, md, github-issue |
--focus | all | Token kind filter: ident, text, vocab, all |
--max-candidates | 200 | Maximum items in output |
-o, --output | stdout | Output file path |
Reports: MATCHED, DRIFTED, SPEC_ONLY (spec with no impl match), IMPL_ONLY (impl with no spec match), SHALLOW (matched to type-only stubs without function implementations).
Generates requirement → implementation mapping for auditing.
--fail-on | Description |
|---|---|
none | Always pass |
drifted | Fail if any DRIFTED |
spec-only | Fail if any SPEC_ONLY |
shallow | Fail if any SHALLOW (type-only stubs without function implementations) |
any | Fail on DRIFTED, SPEC_ONLY, SHALLOW, or CONFLICT |
Reruns alignment when spec or implementation inputs change.
Generates actionable suggestions to close spec↔impl gaps.
Use --threshold 0.3 for SDD alignment commands. The default 0.6 is
too high because SDD acceptance criteria are short text matched against
code + doc comments, not full-document similarity.
The SDD pipeline works with any language that has a KGF spec.
For spec align to work, the language's KGF must:
doc must be non-emptyNL? or NL* after doc:DocComment?Verify with: indexion kgf edges <file> — if declares edges lack doc=,
the KGF needs fixing.
indexion --version # must be installed
indexion kgf edges <any-source-file> # must detect language and show edges# For RFC: save as markdown or .rfc.txt
indexion spec draft --output .kiro/specs/<feature>/requirements.md rfc_document.md
# For ISO/IEC standards: extract text from PDF with cleanup, then draft
python3 scripts/extract_iso_text.py spec.pdf <start_page> <end_page> spec.spec.txt
indexion spec draft --output .kiro/specs/<feature>/requirements.md spec.spec.txt
# Create spec.json (set requirements.generated=true, approved=true)# Check requirements ↔ original spec alignment
# (spec align now accepts document files as impl when no code files are found)
indexion spec align diff .kiro/specs/<feature>/requirements.md spec.spec.txt \
--format markdown --threshold 0.3
# SPEC_ONLY items = requirements not covered by original spec
# DRIFTED items = requirements using different vocabulary from original spec# 1. Source spec ↔ requirements (fidelity)
indexion spec align diff requirements.md source-spec.spec.txt --threshold 0.3
# 2. Requirements ↔ design (design coverage)
indexion spec align diff requirements.md design.md --threshold 0.3
# 3. Requirements ↔ implementation (impl coverage) — after $kiro-impl
indexion spec align diff requirements.md src/ --threshold 0.3indexion spec align status $SPEC_DIR/requirements.md src/ --threshold 0.3 --fail-on driftedindexion spec align diff $SPEC_DIR/requirements.md src/ --format markdown --threshold 0.3
indexion spec align status $SPEC_DIR/requirements.md src/ --threshold 0.3 --fail-on anyAfter completing each task (commit), run:
indexion spec align diff ... --threshold 0.3
indexion spec align status ... --threshold 0.3 --fail-on any
If DRIFTED, SPEC_ONLY, or SHALLOW items remain for the requirement
your task addresses, fix them before moving to the next task.
- DRIFTED: add spec vocabulary to public declaration doc comments
- SPEC_ONLY: implement the missing requirement
- SHALLOW: add non-trivial function implementations (>4 lines) to the
SAME FILE where the matched type is defined. Do not add logic in a
separate file — SHALLOW checks per-file.
When all tasks are done, spec align status --fail-on any must exit 0
with Shallow: 0.