← Catalog

pi-spec-mode

Pi extension that adds a /spec mode: write, agree, verify and hand over feature specs.

Extension

Install

Install with PiG

pig install npm:pi-spec-mode

Install with Pi

pi install npm:pi-spec-mode
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 1.1.1 (README.md). PiG does not review it.

pi-spec-mode ✎

npm version License: MIT pi extension node

A pi extension that adds a specification mode: write a feature spec with the agent, agree it, keep it true to the code, and hand it to plan mode to build.

A spec says what a feature is and how it behaves; it never describes code.

Install

pi install npm:pi-spec-mode        # or: pi install git:github.com/psychobarge/pi-spec-mode
pi -e ./                           # try a local checkout

/spec implement also needs @narumitw/pi-plan-mode. Everything else works without it.

Use

CommandWhat it does
/specMenu of the commands available right now
/spec startEnter spec mode
/spec <request>Enter spec mode and send the request
/spec listList every spec with its status and last check
/spec agree [spec]Mark a Draft spec Agreed (default: the current one)
/spec refuse [spec]Mark a spec Refused and move it to specs/Refused/
/spec restore <spec>Bring a refused spec back as Draft
/spec obsolete <spec> [replacement]Retire an implemented spec to specs/Obsolete/
/spec purgeDelete the obsolete specs (asks first)
/spec verify [spec...]Check specs: implemented against the code, others against the other specs
/spec verify_oldestCheck the verifyCount specs verified longest ago, without the list
/spec implement <spec>Hand an Agreed spec to plan mode
/spec templateCreate a spec template fitted to your project
/spec settingsShow and change the settings
/spec exitLeave spec mode

Commands that take a spec accept its number (/spec agree 0003) or file name. Typed without one (/spec implement), agree, refuse, verify, restore, obsolete and implement open the same spec picker as the /spec menu; agree, refuse and verify act on the spec in progress if there is one.

In spec mode

  • The footer shows ✎ spec-mode 0003 · Draft (✎ spec-mode (YOLO) 0003 · Draft when the yolo setting is on).
  • The agent reads the whole project, runs only read-only shell commands, and writes only Markdown files in the specs folder — unless the yolo setting is on (see Settings).
  • It asks you decisions through spec_question, and calls spec_complete when the spec is ready: you then pick Agree, Keep discussing or Leave.
  • Before that, it checks the new spec against the existing ones (titles and goals, plus a full read of related Agreed / Implemented specs) and asks about any contradiction.
  • It cannot agree a spec or mark one Implemented itself; that stays your call.
  • The /spec menu only offers list and exit, plus agree, verify and refuse for the spec in progress once it is written. verify_oldest, implement, restore, obsolete, purge, template, settings and refusing or verifying another spec are refused until /spec exit.

Spec lifecycle

Specs live in specs/NNNN_spec_<feature>.md.

flowchart LR
    start(( )) -->|/spec request| Draft
    Draft["<b>Draft</b><br/>spec_question, edits"] -->|/spec agree| Agreed
    Agreed -->|spec edited| Draft
    Agreed -->|"/spec implement,<br/>then plan mode"| Implemented["<b>Implemented</b><br/>specs/Implemented/"]
    Draft -->|/spec refuse| Refused
    Agreed -->|/spec refuse| Refused
    Refused["<b>Refused</b><br/>specs/Refused/<br/>skipped by /spec verify"] -->|/spec restore| Draft
    Implemented -->|"/spec obsolete,<br/>replaced or dropped"| Obsolete["<b>Obsolete</b><br/>specs/Obsolete/<br/>skipped by /spec verify,<br/>never read by the agent"]
    Obsolete -->|/spec purge| Deleted(( ))
  • Setting Status to Refused or Obsolete by hand moves the file too.
  • A spec number is never reused, even after /spec purge (it records the last one in specs/.last_purged: commit it).

Verify

/spec verify checks an Implemented spec against the code, and a Draft or Agreed spec against the other specs (contradictions, duplicates, missing dependencies): a rule not built yet is not reported. It fixes any spec that drifted. Refused and obsolete specs are skipped.

  • /spec verify (or verify in the /spec menu) opens a list of the specs with the verifyCount verified longest ago already ticked: Enter on a spec ticks or unticks it, Enter on the first line starts the run. Without an interactive UI, it checks those verifyCount specs.
  • /spec verify_oldest checks those verifyCount specs directly, without the list.
  • /spec verify 3 5 checks the specs you name, even if already verified today.
  • In spec mode, /spec verify checks the spec in progress, then spec mode resumes.

An Agreed spec it had to change goes back to Draft; at the end you are asked whether to agree it again (or later, with /spec agree).

flowchart LR
    start(( )) -->|/spec verify| Queue["<b>Queue</b><br/>verifyCount specs,<br/>oldest Last verified first"]
    Queue --> Check["<b>Check each claim</b><br/>rules, Feedback, numbers, header"]
    Check -->|spec wrong, code works| Fix["fix the spec"]
    Check -->|code broken| Report
    Check -->|a rule must change| Ask["spec_question<br/>to the user"]
    Check -->|undecidable| Report
    Fix -->|Agreed spec changed| Draft["back to <b>Draft</b>"]
    Fix --> Stamp
    Ask --> Stamp
    Check -->|all claims hold| Stamp["Last verified = today"]
    Stamp --> Report["<b>Report</b><br/>then back to the previous mode"]
    Draft --> Offer["<b>Agree again?</b><br/>one question per changed spec"]

Make your own template (do it)

The bundled template is generic on purpose. Good specs come from a template in your project's language: a game needs feel and balance numbers, an API needs contracts and error codes, a mobile app needs screens and offline states. See a complete spec for the expected level of detail.

/spec template

The agent copies the generic template to specs/spec_template.md, looks at your project, and rewrites it to fit.

Reread the result. Every spec is checked against this template when you agree it, so a wrong rule here spreads everywhere. Rename sections, rewrite hints, delete what never applies. After this run the template is yours: the agent only edits it during /spec template.

Settings

Global: ~/.pi/agent/pi-spec-mode.json. Per project (trusted projects only): .pi/pi-spec-mode.json. Edit by hand or with /spec settings.

{
  "specsDir": "specs",
  "language": "English",
  "verifyCount": 2,
  "renameSession": false,
  "renamePlanSession": false,
  "yolo": false
}
KeyMeaning
specsDirSpecs folder, inside the project
languageLanguage specs are written in
verifyCountSpecs checked per /spec verify run
renameSessionRename the session spec NNNN creation when a spec is created
renamePlanSessionRename the session spec NNNN planning on /spec implement
yoloDisable spec mode's tool gating (any tool, any bash command, writes anywhere). Default false

An invalid value is ignored with a warning and the default is used.

Warning: with yolo true, the agent can edit any file and run any command — the "enforced" promise of spec mode does not apply, and specs agreed in such a session were produced without the usual guardrails. The spec template stays protected from the write and edit tools: /spec agree measures every spec against it. The Status rules, /spec verify and spec_complete still apply to write and edit tool calls; shell writes to a spec file are not intercepted.

Develop

npm install
npm test          # node --test, no build step: pi loads the TypeScript directly
npm run typecheck

Known limitations

  • The conflict check is a model instruction, not code, and only sees each spec's title and Goal section. A conflict hidden in an unrelated-looking spec can be missed; /spec verify is the safety net. Keep a Goal heading in your template.
  • "Never read an obsolete spec" is a model instruction too. Run /spec purge to be sure.
  • Symlinked specs are ignored, so nothing is written outside the specs folder (unless yolo is on).

Changelog

See CHANGELOG.md.

My other pi extensions & tools

Extension/toolWhat it doesInstall
pi-deepseek-peakShows DeepSeek peak-hour status and corrects session pricespi install npm:pi-deepseek-peak
pi-deepseek-visionGives DeepSeek vision through a local or remote vision LLMpi install npm:pi-deepseek-vision
pi-sessionsTerminal UI for browsing, previewing, resuming and managing Pi sessionspipx install pi-sessions-tui

License

MIT