The Factree spec file format. Use whenever reading, writing or editing a .factree/specs/<capability>/spec.md file, building or verifying from one, citing requirement or scenario ids in tests or commits, or answering questions about what a Factree spec contains.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Spec Format?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/factree-dev-spec-format)
---
name: spec-format
description: The Factree spec file format. Use whenever reading, writing or editing a .factree/specs/<capability>/spec.md file, building or verifying from one, citing requirement or scenario ids in tests or commits, or answering questions about what a Factree spec contains.
user-invocable: false
---
# Factree spec format
A spec is where a requirement meets the code. It states how one capability behaves, in a form someone who has never seen the code could check, and records where that behaviour lives, why it is built that way, and what is still unknown.
The requirement that prompted it (a ticket, a wiki page, a list in chat) stays where it lives. The spec links to it.
## Where specs live
In the checkout's `.factree/specs/`, one folder per capability:
```
.factree/specs/<capability>/
spec.md # this format
```
The folder name is the capability id in kebab-case: `.factree/specs/link-report/spec.md`. Later stages of the factory may add files beside it; this skill defines only `spec.md`.
Specs are local to the machine. Git ignores `.factree/`, which has three consequences:
- Never stage or commit a spec, and never force-add one. A deleted spec cannot be brought back from git.
- Searches may skip ignored files. List existing specs by path (`ls .factree/specs`) and read them by path; an empty search result does not mean there are none.
- Another git worktree or clone of the repository does not contain them.
A `specs/` folder at the top of a repository is the repository's own. Factree neither reads nor writes it.
A **capability** is a coherent behaviour a user or caller would name: "report export", "link revocation", "SSO sign-in". Not a page, an endpoint, a file or a ticket. A ticket is a source; one capability serves many tickets over its life. If a spec grows past about 10 requirements, it is probably two capabilities.
Factree watches these files. A new or changed `spec.md` appears on The Line within a couple of seconds, with any problems the validator found. Nobody has to register it.
## File structure
Sections appear in this order. `Observations` and `Sketch` are optional; every other section is required, even if it only says "None yet."
```markdown
---
id: link-report # must match the folder name
title: Link reports for teams
owner: john
sources: # where the requirements came from
- https://example.atlassian.net/wiki/spaces/PROD/pages/123
- JIRA-482
retired: [] # ids that were removed and must never be reused
---
# Link reports for teams
## Purpose
## Scope
## Observations
## Requirements
## Sketch
## Code
## Decisions
## Open questions
```
The front matter holds only what a person writes. Whether a spec is a draft or approved, who approved it and when, and what has been built and proved are **not** in the file: Factree records them as events, so the file never has to be edited to change status. See **Status**.
### Purpose
One to three sentences: what the capability is for and who it serves. This is the lasting reason, not the latest ticket.
### Scope
Three lines, `**In:**`, `**Out:**` and `**Anti-goals:**`. Out-of-scope items are as important as in-scope ones. Anti-goals say what would make the work a failure even if it technically works ("an export that silently drops rows"); the validator warns when they are missing.
### Observations
What the code does **today** in the area this spec covers, found by reading it. Use this when a spec is written for code that already exists. Each line has an id and a file reference:
```markdown
- O1 Exports already exist for single links only, via `GET /links/:id/export` (`src/exports/routes.ts`)
- O2 Deleted links are kept, marked with `deleted_at`; most queries filter them with `active()` (`src/models/link.ts`)
```
Observations are facts, not intentions. If observed behaviour must be kept and matters, promote it to a requirement with `Source: O2`. Cite the file; add a line number only when the file is long enough to need one, because line numbers go stale first.
### Requirements
OpenSpec's format, with ids in the names:
```markdown
### Requirement: R2 Export contents
The export service SHALL include one row per active link in the selected team.
Source: JIRA-482
Blocked by: Q2
#### Scenario: S1 Mixed team
- **GIVEN** a team with 2 active and 1 deleted link
- **WHEN** an admin exports the team
- **THEN** the report has a header row and 2 data rows
#### Scenario: S2 Empty team
- **GIVEN** a team with no links
- **WHEN** an admin exports the team
- **THEN** the report has only the header row
- **AND** the download still succeeds
```
Rules:
- The heading is `### Requirement: R<n> <Name>`. The first line under it is the requirement statement: one behaviour, containing SHALL or MUST (SHOULD or MAY only when genuinely optional). It may instead name the source section it implements as its one behaviour ("SHALL behave as SHORT-43 §3 states"), quantified by that section and its scenarios.
- `Source:` (optional) points to the requirement's origin: an item in `sources`, a section of it, or an observation (`O2`). `Blocked by:` (optional) lists open questions that must be answered before this requirement can be built.
- Every requirement has at least one scenario. Scenarios cover failure and edge cases, not only the happy path.
- The heading is `#### Scenario: S<n> <Name>`, where the name says which case it covers. Steps are bullets starting `**GIVEN**`, `**WHEN**`, `**THEN**`, with `**AND**` for extra steps. WHEN and THEN are required; GIVEN is required unless there is genuinely no precondition.
- No implementation detail in requirements or scenarios: no table names, libraries or function names. Those go in Code or Decisions.
- No vague words. "Fast", "large", "secure", "gracefully", "soon" and their kind mean nothing to a test; say how much. The validator flags them.
### Sketch
Optional. For anything the user will look at (a page, a screen, a layout): a text sketch of it in one fenced code block, exactly as it should read. Leave the section out when there is nothing to look at.
```
Team: Finance admins [ Download report ]
─────────────────────────────────────────────
Name Email Expires
```
**A flow:** when the spec has screens or states, the Sketch is a `flow` block instead: one line per step, the first line starting the main path, each naming in brackets the scenarios that prove it. A step with no scenario is a gap, and the validator says so. It reports an error for a line without `->` and for any cited scenario the spec does not have.
```flow
Team page -> Exporting : export [R2.S1, R2.S2]
Exporting -> File : rows [R2.S1]
Exporting -> File : no rows [R2.S2]
Exporting -> Busy : export again [R4.S1]
File -> Team page : back
```
### Code
Where the behaviour lives, kept short enough to scan: entry points, key modules, important interfaces, with paths. Write "Not built yet." for new capabilities. Update it when code moves.
### Decisions
```markdown
- D1 Stream rows from a database cursor, because teams reach 100k links. (2026-11-15, John Doe)
- D2 Exclude deleted links, because the export feeds BI of current holders. Resolves Q1. (2026-11-15, Priya)
- D3 ~~Generate exports synchronously~~ Superseded by D4. (2026-11-12, John Doe)
```
- Each decision says what was decided, **because** why, and who decided it and when.
- A decision is recorded only when a person made it, or explicitly delegated it ("you decide" → recorded as `Claude, delegated by <name>`). Claude may propose; a proposal goes in Open questions until someone agrees.
- Decisions are never deleted. A replaced decision is struck through and marked `Superseded by D<n>`.
### Open questions
```markdown
- Q2 Should exports respect field-level permissions? Owner: Priya. Blocks: R5.
- Q3 Do we need an audit log entry per export? Owner: John Doe.
```
- Each question has an owner. `Blocks:` lists the requirements it blocks, mirrored by `Blocked by:` on those requirements.
- When answered, the question is **deleted** and the answer becomes a decision (`Resolves Q<n>`), a requirement change, or both. The list only ever holds what is genuinely open.
## IDs
| Prefix | Scope | Example reference |
|---|---|---|
| `R<n>` | Requirement, unique in the spec | `link-report#R2` |
| `S<n>` | Scenario, unique within its requirement | `link-report#R2.S1` |
| `O<n>` | Observation | `link-report#O2` |
| `D<n>` | Decision | `link-report#D1` |
| `Q<n>` | Open question | `link-report#Q2` |
- IDs are never renumbered or reused. Removing a requirement deletes it and adds its id to `retired` in the front matter. New items take the next unused number.
- The scoreboard, a verifier's rulings and a scenario sent back to build are all keyed by scenario id (`R2.S1`). Renumbering would attach old evidence to a different scenario, which is why ids are permanent.
- Tests cite the scenario they prove in their name or description: `it("excludes deleted links [link-report#R2.S1]")`.
## Status
Status is not in the file. Factree derives it from what has happened:
| Status | Meaning | How it gets there |
|---|---|---|
| draft | Being written or changed | Any spec that has not been approved as it now reads |
| approved | Nothing stands between this text and a build | By the flow, when the agent that wrote or changed it finishes and nothing is open; or by a person's key (`B` or `A` on its page, `npx factree approve <id>`) for a spec written or edited by hand |
- Approval is tied to the spec's **behaviour**: its Purpose, Scope, Requirements and Sketch. Change any of those and the spec is a draft again, and its scenarios are unproven again, until someone approves the new text. Editing Observations, Code, Decisions or Open questions (that block nothing) changes neither.
- A spec cannot be approved while the validator reports an error, or while any requirement is `Blocked by:` an open question. That is the only thing that holds a spec back: nobody is asked to approve a spec that has nothing open.
- An open question that blocks nothing is a recorded call. It holds nothing back.
- A spec an agent wrote or changed is approved by the flow when the agent finishes, and its planner starts by itself. A spec saved by hand waits for one key, so that a save in the middle of an edit starts nothing.
- Only an approved spec is planned and built. Merging the build into a person's branch always stays their key.
## What each reader of a spec is given
- **A builder** gets the whole file.
- **A verifier** gets Purpose, Scope, Requirements and Sketch only, without the `Source:` and `Blocked by:` lines. It never sees Observations, Code or Decisions, so it cannot be led by how the software was or will be built. Anything a verifier needs in order to judge a scenario must therefore be in the scenario itself.
## Checking a spec
`npx factree check <id>` (or with no id, every spec) prints each problem and whether the spec is ready to approve. Errors block approval; warnings are judgement calls. The same findings show beside the spec on The Line.
## Editing an existing spec
- Change behaviour by editing the requirement in place and adjusting its scenarios. Keep its id.
- Adding a case to existing behaviour means adding a scenario, not a requirement.
- A bug that revealed an uncovered case adds a scenario for that case.
- Never delete a decision; supersede it.
- After editing, say what changed by id: added R6, changed R2 (new scenario S3), retired R4, resolved Q1 as D5.