From pharaoh
Generates Superpowers-compatible spec and plan document from sphinx-needs requirements, mapping coverage, identifying gaps, recording decisions, and creating actionable plan tables.
How this skill is triggered — by the user, by Claude, or both
Slash command
/pharaoh:pharaoh-specThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate a self-contained specification and plan document from one or more sphinx-needs
Generate a self-contained specification and plan document from one or more sphinx-needs
requirements. The spec bridges the gap between requirements (the "what") and
implementation (the "how") by pulling full requirement text, mapping existing downstream
coverage, identifying gaps, recording design decisions via pharaoh:decide, and
producing a plan table that feeds directly into pharaoh:plan.
The output is a markdown document in docs/superpowers/specs/ containing requirements,
coverage analysis, gap list, decisions, and an actionable plan table.
pharaoh:plan.decision type configured (see pharaoh:decide Step 1).Execute the following steps in order.
Follow the full detection and data access algorithm defined in skills/shared/data-access.md.
pharaoh.toml for strictness level, workflow gates, traceability requirements, and required_links chains.Present the detection summary before proceeding:
Project: <name> (<config source>)
Types: <list of directive names>
Links: <list of link type names>
Data source: <tier used>
Needs found: <count>
Strictness: <advisory|enforcing>
If detection fails (no project found, no needs in source files), report the issue and ask the user for guidance. Do not proceed with empty data.
Accept one or more requirement IDs from the user's request.
Validate each ID against the needs index. If an ID does not exist:
Resolve to IDs using the needs index. Match by:
If multiple needs match, present candidates and ask the user to choose:
Multiple matches found:
1. REQ_001 (Requirement: Brake response time) [open]
2. REQ_007 (Requirement: Brake pedal response) [approved]
Which requirement(s) should be included in the spec? Enter numbers or IDs.
If exactly one matches, proceed with it and inform the user of the resolved ID.
When called with multiple requirement IDs, produce a single combined spec document covering all of them. Do not produce separate documents per requirement.
For each input requirement, build a complete scope tree.
For each input requirement, retrieve all available fields:
This is the full text -- requirements are the source of truth and must appear verbatim in the spec document.
Starting from each input requirement, follow the link graph recursively to find all downstream needs. Follow all link types (links, implements, tests, and all extra_links) in both directions. Continue until the full downstream tree is mapped.
For each downstream need, collect references only (ID, type, title, status, link type to parent). Do NOT pull full content for downstream needs -- they are resolvable via ubc or source files if needed later.
Assemble a tree showing the requirement at the root with all downstream coverage:
REQ_042 (full text)
+-- SPEC_010 (ref) -- exists, status: open
+-- SPEC_011 (ref) -- exists, status: approved
| +-- IMPL_005 (ref) -- exists, status: open
+-- [gap] -- no spec covers subsystem X
+-- [gap] -- no impl for subsystem X
+-- [gap] -- no test for subsystem X
Determine what downstream coverage is missing using pharaoh.toml required_links chains. If required_links is configured, follow the chain (e.g., req -> spec -> impl -> test). If not configured, infer expected chains from configured types and link types.
Gaps include: requirements with no spec, specs with no impl, impls with no test, and requirements whose content suggests multiple subsystems with only partial spec coverage.
For each gap, record the parent need ID, what is missing, and whether it represents a decision point (ambiguity in decomposition or approach).
Before generating the spec document, present a summary for the user to review:
Scope for REQ_042:
Requirements: 1 (full text included)
Specifications: 2 (references only)
Implementations: 1 (reference only)
Test cases: 0
Gaps: 2 (no spec for subsystem X, no test for IMPL_005)
Decisions needed: 2
For multiple requirements, show a combined summary with the same format.
If the scope is unexpectedly large (more than 30 downstream needs), warn the user and suggest splitting into separate specs per requirement.
Wait for user confirmation before proceeding to Step 5.
For each gap or ambiguity identified in Step 3d, determine whether a design decision is needed.
Decisions are needed when:
For each decision, invoke pharaoh:decide programmatically with all context:
claude (since the AI is generating the spec).accepted (decisions made during spec generation are accepted by default).pharaoh:decide will generate the decision ID, write the RST directive, and return the ID. Collect all decision IDs for use in Step 6.
Important: Write all decisions BEFORE generating the spec document. The spec must reference stable decision IDs, not placeholders.
If all gaps are straightforward (e.g., a missing test case for an existing implementation where the test strategy is obvious), skip decision recording. Note in the spec that no design decisions were required.
Write the spec document to docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md.
YYYY-MM-DD is the current date.<topic> is a short kebab-case slug derived from the requirement title(s) (e.g., brake-response-time).Create the docs/superpowers/specs/ directory if it does not exist.
The spec document MUST contain these sections in this order:
# Spec: <Requirement title(s)>
Generated from sphinx-needs on YYYY-MM-DD.
Source requirements: REQ_042, REQ_043
## Requirements (source of truth)
### REQ_042: <title>
**Status:** <status> | **Tags:** <tag1>; <tag2>
<Full requirement content text pulled verbatim from sphinx-needs.>
### REQ_043: <title>
**Status:** <status> | **Tags:** <tag1>; <tag2>
<Full requirement content text pulled verbatim from sphinx-needs.>
## Existing coverage
| Need | Type | Title | Status | Links |
|------|------|-------|--------|-------|
| SPEC_010 | spec | Signal timing | open | REQ_042 |
| SPEC_011 | spec | Protocol design | approved | REQ_042 |
| IMPL_005 | impl | CAN driver | open | SPEC_011 |
## Gaps
- [ ] No specification covers subsystem X of REQ_042
- [ ] No test case for IMPL_005
- [ ] No implementation for SPEC_010
## Decisions
- DEC_001: Decompose REQ_042 into timing and protocol specifications
- DEC_002: Use CAN bus for sensor communication
> If no decisions were needed, write: "No design decisions required. All gaps are
> covered by straightforward additions."
## Implementation scope
### Needs to create
| Type | Purpose | Links to | File |
|------|---------|----------|------|
| spec | Subsystem X timing | REQ_042 | specifications.rst |
| test | CAN driver verification | IMPL_005 | test_cases.rst |
### Needs to modify
| Need | Change | Reason |
|------|--------|--------|
| SPEC_010 | Update timing constraints | REQ_042 timing budget changed |
> If no needs to create or modify, write "None" for the respective subsection.
## Plan table
| # | Task | Skill | Target | Detail | File | Required |
|---|------|-------|--------|--------|------|----------|
| 1 | Analyze impact | pharaoh:change | REQ_042 | Trace downstream effects | docs/requirements.rst | yes |
| 2 | Author spec | pharaoh:arch-draft | (new) | Subsystem X timing | docs/specifications.rst | yes |
| 3 | Author test | pharaoh:vplan-draft | (new) | CAN driver verification | docs/test_cases.rst | yes |
| 4 | Update spec | pharaoh:arch-draft | SPEC_010 | Timing constraints | docs/specifications.rst | yes |
| 5 | Verify | pharaoh:arch-review, pharaoh:vplan-review | (all) | Check traceability and per-type axes | -- | yes |
pharaoh:plan Step 5.Construct the plan table following pharaoh:plan task sequencing rules.
pharaoh:change task per modified need, or a single task covering all modifications.pharaoh:req-review) covering all created and modified needs.pharaoh:mece task if require_mece_on_release = true in pharaoh.toml, or if the scope involves creating needs at multiple hierarchy levels.Each task row must specify:
pharaoh:change, pharaoh:req-draft, pharaoh:req-review, pharaoh:mece).(new) for needs to create, or (all) for verification tasks.docs/requirements.rst, docs/specifications.rst), or -- if not applicable.yes, no, or recommended based on strictness mode.yes. Optional tasks (like MECE check when not required) are marked recommended.recommended. No task is strictly required.pharaoh:plan Step 5. This ensures the plan can be handed off to pharaoh:plan for execution without reformatting.After generating the spec document, present the file path and offer next steps:
Spec document written to: docs/superpowers/specs/2026-04-07-brake-response-time-design.md
Options:
1. Execute the plan via pharaoh:plan
2. Review or modify the spec first
3. Execute later (plan is saved in the spec document)
pharaoh:plan with the plan table from the spec document.Never auto-execute. Always present the spec and wait for explicit user approval.
Follow the instructions in skills/shared/strictness.md.
recommended instead of yes.Tip: Consider reviewing the spec before executing the plan.
The spec captures design decisions that affect downstream authoring.
yes:
pharaoh:change tasks are required if require_change_analysis = true.require_verification = true.pharaoh:mece tasks are required if require_mece_on_release = true.accepted (same as advisory mode).Both advisory and enforcing modes perform the same scope resolution, gap analysis, and decision recording. Strictness only affects the Required column in the plan table and whether downstream skills gate on prerequisites.
Requirements get full text, downstream needs get references only. The spec is self-contained for requirements but does not duplicate downstream content. Downstream details are resolvable via ubc or by reading source files.
Decisions are written as sphinx-needs objects before the spec references them. Never reference a decision ID that has not been written. Always invoke pharaoh:decide first, collect the ID, then use it in the spec.
Plan table format must match pharaoh:plan exactly. Same column names, same task granularity, same required-field semantics. The plan table in the spec must be directly executable by pharaoh:plan.
Spec doc location defaults to docs/superpowers/specs/ but is overridable. If the user specifies a different path, use it without question.
Never auto-execute. Always present the complete spec document and wait for explicit user approval before invoking any downstream skill. This applies even if the plan has only one task.
When called with multiple requirement IDs, produce a single combined spec. Do not generate separate documents per requirement. The scope tree, gap analysis, and plan table cover all input requirements together.
Keep the spec document focused. Do not include implementation details, code snippets, or design elaborations beyond what the decisions capture. The spec is a bridge document -- it connects requirements to a plan, not a detailed design document.
No session state changes from spec generation alone. Generating and writing the spec document does not modify .pharaoh/session.json. Only decision recording (via pharaoh:decide) and plan execution (via pharaoh:plan) update session state.
User request: pharaoh:spec REQ_001
Step 1 -- Data access detects:
Project: Brake System (ubproject.toml)
Types: req, spec, impl, test, decision
Links: links, implements, tests, decides
Data source: Tier 3 (raw file parsing)
Needs found: 12
Strictness: advisory
Step 2 -- Input: REQ_001. Validated against needs index. Found: REQ_001 (Brake response time).
Step 3 -- Scope resolution:
Full text retrieved for REQ_001:
Downstream trace:
REQ_001 (full text)
+-- SPEC_001 (ref) -- Signal timing, status: open
| +-- IMPL_001 (ref) -- CAN driver, status: open
+-- [gap] -- no spec for subsystem X (pedal sensor interface)
+-- [gap] -- no impl
+-- [gap] -- no test
+-- [gap] -- no test for IMPL_001
Gaps identified:
Step 4 -- Scope summary presented:
Scope for REQ_001:
Requirements: 1 (full text included)
Specifications: 1 (reference only)
Implementations: 1 (reference only)
Test cases: 0
Gaps: 2 (no spec for pedal sensor interface, no test for IMPL_001)
Decisions needed: 2
User confirms: proceed.
Step 5 -- Decisions recorded via pharaoh:decide:
DEC_003: "Decompose pedal sensor interface into separate specification"
DEC_004: "Use hardware-in-the-loop testing for CAN driver verification"
Step 6 -- Spec document generated at docs/superpowers/specs/2026-04-07-brake-response-time-design.md with:
recommended):| # | Task | Skill | Target | Detail | File | Required |
|---|---|---|---|---|---|---|
| 1 | Analyze impact | pharaoh:change | REQ_001 | Trace downstream effects of new spec | docs/requirements.rst | recommended |
| 2 | Author spec | pharaoh:req-draft | (new) | Pedal sensor interface timing spec | docs/specifications.rst | recommended |
| 3 | Author test | pharaoh:req-draft | (new) | CAN driver HIL test case | docs/test_cases.rst | recommended |
| 4 | Verify coverage | pharaoh:req-review | (all) | Check REQ_001 traceability chain | -- | recommended |
Step 8 -- Handoff:
Spec document written to: docs/superpowers/specs/2026-04-07-brake-response-time-design.md
Options:
1. Execute the plan via pharaoh:plan
2. Review or modify the spec first
3. Execute later (plan is saved in the spec document)
User request: pharaoh:spec REQ_001 REQ_002
Step 1 -- Same detection as Example 1.
Steps 2-3 -- Both IDs validated. Scope resolution finds full downstream coverage for both requirements (each has spec, impl, and test in approved status). No gaps, no decisions needed.
Step 4 -- Scope summary:
Scope for REQ_001, REQ_002:
Requirements: 2 (full text included)
Specifications: 2 (references only)
Implementations: 2 (references only)
Test cases: 2 (references only)
Gaps: 0
Decisions needed: 0
Steps 5-6 -- Decisions skipped. Spec document generated at docs/superpowers/specs/2026-04-07-brake-system-design.md with both requirements in full text, a complete coverage table (6 downstream needs), empty gaps section ("No gaps identified"), empty decisions section, and no plan table ("No tasks required. All requirements have complete traceability chains.").
Step 8 -- Handoff offers: review the spec, run pharaoh:req-review to confirm traceability, or done.
npx claudepluginhub useblocks/pharaoh --plugin pharaohCreates or updates SPEC.md documents from requirements, notes, or interview output, structuring into sections for goals, design, edge cases, security, testing, and success criteria. Use for feature specs.
Authors, updates, and validates atomic functional and non-functional requirements with traceability matrices, validation packs, and explicit human-in-the-loop approvals. Use for creating or reviewing requirements as source of truth.
Analyzes sphinx-needs projects for gaps, redundancies, inconsistencies in requirements traceability, orphans, status contradictions, and ID/schema validation.