Give your coding agent the specs for one OpenSpec task.
spec-ctx is a local CLI. It uses stable IDs to link OpenSpec tasks to requirements, scenarios, and tagged code and tests. Run context before editing to see what applies and where it came from.
Listed in the OpenSpec Community (page)
npx -y spec-ctx context add-mfa/1.1Trimmed output from an example OpenSpec project.
-- add-mfa/1.1 | openspec/changes/add-mfa/tasks.md:3 | open | requested
- [ ] 1.1 Add the TOTP prompt to the login form [REQ-UA-002]
-- REQ-UA-002 | openspec/changes/add-mfa/specs/user-auth/spec.md:3 | ref from add-mfa/1.1
### Requirement: REQ-UA-002 TOTP second factor
The system SHALL ask for a TOTP code after a correct password.
#### Scenario: SCN-UA-002-1 Correct code
- **WHEN** a user enters a correct TOTP code
- **THEN** the user is logged in
-- src/login.ts:1 | implements REQ-UA-002 | tagged
-- tests/login.test.ts:1 | covers REQ-UA-002 | tagged
Each block shows its source and how it relates to the task. Retrieval runs with or without the OpenSpec CLI. It makes no LLM call and runs no server.
Requires Node.js 22 or later. Run these commands from your project root.
npx -y spec-ctx init
npx -y spec-ctx adoptinit creates spec-ctx.toml and updates .gitignore. adopt adds stable IDs to requirement and scenario headers in your specs and active changes. It records the edits in adopt-report.md. To preview the edits, run npx -y spec-ctx adopt --dry-run before adopting.
adopt --dry-run exits 1 when headers need IDs. To undo adoption, revert the commit that contains its edits.
Pick a task in openspec/changes/<change>/tasks.md and add the ID of a requirement it implements.
- [ ] 1.1 Add the TOTP prompt to the login form [REQ-UA-002]Then ask for its context. Use your change name and task number in place of add-mfa/1.1.
npx -y spec-ctx context add-mfa/1.1Your agent can run the same command alongside your usual OpenSpec workflow. If the task has no requirement citation, context uses its change and any files named on the task line, and tells you the citation is missing.
Start with one task. Add a REQ-UA-002 comment in the implementation and a Covers: REQ-UA-002 comment in the test to include those locations in the bundle.
Want a ready-made example? Try the toy project.
| Start with | Run |
|---|---|
| A task | npx -y spec-ctx context add-mfa/1.1 |
| A requirement ID | npx -y spec-ctx context REQ-UA-002 |
| A tagged source file | npx -y spec-ctx context src/login.ts |
| An OpenSpec change | npx -y spec-ctx context add-mfa |
| A keyword | npx -y spec-ctx query totp |
context follows task citations, code and test tags, and links from the OpenSpec folder structure. It uses a character budget and marks content omitted for size. Use bundle <ID> to read an individual entry or related <ID> to inspect its links. References to a requirement ID survive a heading rename. How retrieval works
The context ratio divides the average task bundle size by the total indexed spec text, in characters. The numbers are self-reported from this repository. They are no independent benchmark or measure of tokens, cost, or accuracy.
The newest file is docs/metrics/2026-12-01.md.
| change | Context ratio | Passing checks | Stale evidence reopens | Median task seconds | Open findings |
|---|---|---|---|---|---|
| total | 0.0115 (n=222) | 0.96 (388/404) | 113 (of 246 reopens) | 48 (n=222) | 0 (0 baselined + 0 new) |
Install the specctx-run skill with npx -y spec-ctx init --skills. An agent using the skill can pick the next task, load its context, and run its Verify: command before marking it done. task done records evidence. A passing Verify shows that the configured check passed. It does not prove the implementation is correct. handoff write saves progress for the next session.
check reports broken links. check --strict can flag stale evidence. The GitHub Action runs specctx gate. Set [gate] openspec to also run the validate of the OpenSpec CLI after the native one. For rerun: true, see the security boundary.
Agent skill · Full loop transcript
- Upgrading from 0.6.0: a
[gate] openspeckey now runs the OpenSpec validate after the native one. From 0.6.0 - OpenSpec matches a scenario by its full title. To rename a scenario, remove it and add it again with a new ID. Details
- The local run journal lives in
.ctx/local/. SetSPECCTX_JOURNAL=0to turn it off. - Archived: 001 to 025, 027 to 034, 036 to 077, 080, 081, 082, and 083.
- The ID scheme has a proposal in OpenSpec#1967.