Agent skill

Reverse Spec From Code

by BlackBeltTechnology in BlackBeltTechnology/pi-agent-dashboard

Reverse-generate OpenSpec capability specs (openspec/specs/<cap/spec.md) from code that lacks them, or reconcile an existing stale spec with --refresh, using parallel subagents.

MITAuto-check passedAgent Workflows

Install Reverse Spec From Code

skills CLI
$ npx skills add BlackBeltTechnology/pi-agent-dashboard --skill reverse-spec-from-code -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install BlackBeltTechnology/pi-agent-dashboard reverse-spec-from-code --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/BlackBeltTechnology/pi-agent-dashboard.git skills-src && mkdir -p .claude/skills && cp -r skills-src/packages/openspec-workflow/.pi/skills/reverse-spec-from-code .claude/skills/reverse-spec-from-code && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
reverse-spec-from-code
GitHub stars
315
Token cost
~2.4k tokens
SKILL.md length
1,116 words
Files
5
Skills in repo
66
Repo updated
First seen
Licence
MIT

At a glance

Reverse-generate OpenSpec capability specs (openspec/specs/<cap/spec.md) from code that lacks them, or reconcile an existing stale spec with --refresh, using parallel subagents.

  • Works in 6 steps: Resolve target + scope. User names a… → Discover capability boundaries. Spawn… → Skip already-specced capabilities. For… → …
  • Tasks that involve Subagents
  • SKILL.md covers When to use, Core principle (the lever that…, Fitness, honestly and Procedure, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Reverse Spec From Code is an agent skill from BlackBeltTechnology/pi-agent-dashboard. Reverse-generate OpenSpec capability specs (openspec/specs/<cap/spec.md) from code that lacks them, or reconcile an existing stale spec with --refresh, using parallel subagents. Fans out one blind generator per capability, audits each spec against the code for hallucinations, and promotes only on user confirm. Use on "generate specs from code", "backfill openspec specs", "refresh a stale spec".

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files (for example `prompts/auditor.md`, `prompts/discovery.md` and `prompts/generator.md`).

It sits in Agent Workflows, covering Subagents. The repository describes itself as: Real-time web dashboard for pi coding-agent sessions. Multi-session view, live chat mirroring, integrated terminal, diff viewer, pi-flows execution, and mobile-first remote… The licence is MIT.

When your agent uses it

  • Tasks that involve Subagents

Example prompts

  • “generate specs from code”
  • “backfill openspec specs”
  • “refresh a stale spec”
  • “/reverse-spec-from-code”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Resolve target + scope. User names a directory/package (e.g. packages/server)
  2. Discover capability boundaries. Spawn ONE discovery subagent
  3. Skip already-specced capabilities. For each manifest entry, if
  4. Generate in parallel (blind). Fan out ONE generator subagent per remaining
  5. Audit in parallel (code-grounding). Fan out ONE auditor subagent per
  6. Revise if needed. For any spec with verdict: revise, re-spawn its

What it can do on your machine

Read from SKILL.md and the folder at commit e23e533. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Reverse Spec From Code loads about 2.4k tokens when it runs. Until then it costs about 106 tokens; SKILL.md has 1,116 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~106
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from BlackBeltTechnology/pi-agent-dashboard at commit e23e533, republished under its MIT licence (© BlackBeltTechnology). 1,116 words, ~2,421 tokens.

Download SKILL.mdSave it as .claude/skills/reverse-spec-from-code/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
reverse-spec-from-code
description
Reverse-generate OpenSpec capability specs (openspec/specs/<cap>/spec.md) from code that lacks them, or reconcile an existing stale spec with `--refresh`, using parallel subagents. Fans out one blind generator per capability, audits each spec against the code for hallucinations, and promotes only on user confirm. Use on "generate specs from code", "backfill openspec specs", "refresh a stale spec".

reverse-spec-from-code

Turn spec-less code into OpenSpec capability specs so kb_search has high-signal, consistently-formatted behavioral documents to index. Tuned via a blind generate→judge loop against 6 real specs: requirement coverage 97%, scenario coverage 91% (see docs/research/reverse-spec-from-code.md for the tuning record

  • a model-loss test across opus / deepseek-flash / haiku).

Scratch MUST live OUTSIDE openspec/ (kb indexes openspec/). Use the gitignored repo-root dir .reverse-spec-scratch/ — otherwise every draft pollutes kb_search with duplicate spec chunks. Promotion MOVES the file into openspec/specs/ (the only kb-indexed copy).

When to use

  • A package/directory under packages/ has behavior but no openspec/specs/<cap>/spec.md.
  • You want to enrich kb_search (it indexes openspec/ markdown) with behavioral specs.
  • An existing spec is stale and you want a code-current reconciliation (--refresh).

Skip for a single trivial file, or when the capability already has an accurate spec.

Core principle (the lever that matters)

A capability's contract is not confined to one file. The single biggest quality driver is making each generator FOLLOW the behavioral contract across file boundaries: every emitted message/event, registry write, spawned/killed process, config read, or DOM attribute is a contract with another component and must be spec'd too. In tuning this moved requirement coverage from 40% to 95% on the cross-cutting capability. The generator prompt (prompts/generator.md) enforces this in STEP 1 — do not weaken it.

Fitness, honestly

"Match an existing spec" is a PROXY, not the goal. Real specs drift from code. The goal is a spec that accurately describes current code and is searchable. Target: high requirement coverage + zero code-ungrounded hallucination. Code-current divergence from a stale spec is a win, not a miss.

Procedure

  1. Resolve target + scope. User names a directory/package (e.g. packages/server) and optionally a single capability. Confirm the target path exists.

  2. Discover capability boundaries. Spawn ONE discovery subagent (prompts/discovery.md, model @compact is fine) that clusters the target's files into capabilities using the directory AGENTS.md tree (kb agents <dir>, kb_search --doc-type agents) + grep. It returns a manifest: [{ capability, purpose_hint, files[] }]. For a single-capability target you may skip this and build the manifest by hand.

  3. Skip already-specced capabilities. For each manifest entry, if openspec/specs/<capability>/spec.md exists and --refresh was NOT requested, drop it (report as skipped). With --refresh, keep it and reconcile.

  4. Generate in parallel (blind). Fan out ONE generator subagent per remaining capability IN A SINGLE MESSAGE (prompts/generator.md). Each reads code only — never an existing spec — and writes .reverse-spec-scratch/<capability>/spec.md. Pass capability, purpose_hint, start files, and the output path. Model: a fast/cheap model (@fast/@compact) is viable AS LONG AS the format gate (step 6.5) and the @research auditor run — see "Model choice" below.

  5. Audit in parallel (code-grounding). Fan out ONE auditor subagent per generated spec IN A SINGLE MESSAGE (prompts/auditor.md, model @research). Each verifies the generated spec against the ACTUAL code and returns strict JSON: hallucinated_requirements[] (in spec, not in code), missing_behaviors[] (in code, not in spec), format_ok, verdict (pass|revise). No real spec is needed — the code is the oracle.

  6. Revise if needed. For any spec with verdict: revise, re-spawn its generator with the auditor's findings appended (remove the listed hallucinations, add the listed missing behaviors). One revise pass is usually enough; re-audit only if the first audit was severe.

6.5. Format gate (openspec validate) — HARD, deterministic. openspec validate only reads specs under openspec/specs/, so validate each scratch spec via a throwaway id, then delete it:

bash
for c in <cap1> <cap2> ...; do
  d="openspec/specs/_rsfc-val-$c"; mkdir -p "$d"
  cp ".reverse-spec-scratch/$c/spec.md" "$d/spec.md"
  openspec validate "_rsfc-val-$c" --type spec 2>&1 | grep -qi "is valid" \
    && echo "$c: VALID" || echo "$c: INVALID"
  rm -rf "$d"
done

Any spec that is INVALID is treated exactly like verdict: revise with reason "format: openspec validate failed" — re-spawn its generator emphasizing the FORMAT rule (no tables, no bold **Scenario:**, no numbered requirements), then re-run this gate. A spec that fails validate is NEVER promoted. Cheap generator models fail here most often — this gate is what makes them safe.

  1. Present + promote on confirm. Show the user: per-capability spec path, requirement count, and audit + validate summary (skipped / passed / revised / valid). Only specs that BOTH audit-pass AND validate-pass are promotable. Use ask_user (confirm or multiselect) to choose which to promote. On confirm, MOVE .reverse-spec-scratch/<cap>/spec.md → openspec/specs/<cap>/spec.md (create the dir; move, don't copy, so no duplicate stays under an indexed root). NEVER write openspec/specs/ without explicit confirm.

  2. Verify KB indexing. After promotion, run kb_search "<a phrase from a new spec>" to confirm the spec is discoverable. Report the result.

Show full SKILL.md (422 more words)Show less

Subagent routing

RolePromptModelAccessParallel
discoveryprompts/discovery.md@compactread-only1 pass
generatorprompts/generator.md@research (max quality) or @fast/@compact (cheap; needs gate)read+write (scratch)N in one message
auditorprompts/auditor.md@research (keep strong — the safety net)read-onlyN in one message

Fan out generators (then auditors) as multiple Agent calls in a SINGLE message so they run concurrently. One capability per subagent — isolated context.

Model choice (from the model-loss test in docs/research/reverse-spec-from-code.md)

Judge/generator swap on the 6 ground-truth specs (judge held @research):

generatorreq covscen covopenspec validate
opus (@research)97%91%6/6
deepseek-flash (@fast) + format directive96%90%6/6
haiku (@compact), no directive88%81%3/6
  • "fast" ≠ "weak": @fast (deepseek-flash) nearly matched opus on coverage.
  • Cheap models lose most on FORMAT and on the HARDEST cross-file capabilities — the format gate (6.5) fixes the former; extra revise cycles fix the latter.
  • Recommended cost config: @fast generator + format gate + @research auditor
    • revise loop ≈ opus quality at a fraction of the cost. Keep the auditor strong; it is the hallucination safety net regardless of generator model.

Output format (what generators produce)

Full-form OpenSpec spec (post-archive shape, NOT the ## ADDED Requirements delta):

# <capability> Specification

## Purpose
<1-3 sentences>

## Requirements
### Requirement: <short imperative name>
The <subject> SHALL <behavioral obligation>.

#### Scenario: <name>
- **WHEN** <trigger>
- **THEN** <observable outcome>
- **AND** <optional>

Pitfalls

  • Under-scoped input — feeding one file to a cross-cutting capability caps coverage low no matter how good the prompt. Discovery must gather ALL files; the generator must follow references. This is the #1 failure mode.
  • Over-splitting — without a grouping rule the generator emits many tiny requirements. Prompt targets 3-8 grouped requirements with rich scenarios.
  • Visual/detail invention — UI capabilities tempt the model to describe pixels/colors it did not confirm. The prompt forbids unconfirmed detail; the auditor catches the rest.
  • Clobbering real specs / kb pollution — scratch-first in the gitignored repo-root .reverse-spec-scratch/ (NEVER under openspec/, which kb indexes), promote (move) only on confirm.
  • Chasing 100% match to an existing spec — the spec may be stale. The code is the oracle; the auditor checks the code, not the old spec.
  • Cheap-model format breaks — smaller/faster generators (@fast/@compact) tend to emit markdown tables, bold **Scenario:**, or numbered requirements that FAIL openspec validate. The format directive in prompts/generator.md plus the step-6.5 validate gate catch this; never promote a cheap-model spec without running the gate.

Verification

  • Format gate (step 6.5) returned VALID for every promoted spec (openspec validate <capability> --type spec → "is valid"). This is a HARD gate, not an advisory check — an invalid spec is never promoted.
  • Auditor returned verdict: pass (or revise was resolved) for every promoted spec.
  • kb_search "<phrase from a new spec>" returns the new spec.
  • No file under openspec/specs/ was written without user confirm.

© BlackBeltTechnology, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files in packages/openspec-workflow/.pi/skills/reverse-spec-from-code of BlackBeltTechnology/pi-agent-dashboard.

  • SKILL.md
  • prompts/auditor.md
  • prompts/discovery.md
  • prompts/generator.md
  • prompts/judge.md

Open the folder on GitHubat commit e23e533

Compare with similar skills

Reverse Spec From Code next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Reverse Spec From Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Reverse Spec From Code this skillBlackBeltTechnology/pi-agent-dashboard315—~2.4kAutomated safety check: PassMIT
Claude Code Agent Developmentanthropics/claude-plugins-official38k8 repos~2.8kAutomated safety check: PassApache-2.0
Subagent Driven DevelopmentAsvarox/allkaraoke26138 repos~1.2kAutomated safety check: PassNone
Dispatching Parallel Agentsultralisp/ultralisp25841 repos~1.5kAutomated safety check: PassNone
Paseo Advisor Second Opiniongetpaseo/paseo20k1 repos~756Automated safety check: PassCustom licence
Task Observerrebelytics/one-skill-to-rule-them-all3.2k1 repos~12kAutomated safety check: PassCC-BY-4.0

Similar skills

  • Claude Code Agent Development

    anthropics/claude-plugins-official

    Official

    Explains how to write agents for Claude Code plugins: the markdown file with YAML frontmatter, trigger descriptions, model and color settings, and system prompt design.

    38k GitHub starsUsed in 8 repos~2.8k tokens
    Agent WorkflowsAuto-check passed
  • Subagent Driven Development

    Asvarox/allkaraoke

    A skill your agent uses when executing implementation plans with independent tasks in the current session

    261 GitHub starsUsed in 38 repos~1.2k tokens
    Agent WorkflowsAuto-check passed
  • Dispatching Parallel Agents

    ultralisp/ultralisp

    A skill your agent uses when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

    258 GitHub starsUsed in 41 repos~1.5k tokens
    Agent WorkflowsAuto-check passed
  • Launches one separate agent through Paseo to give a second opinion on the current task, with a self-contained briefing and no permission to edit files.

    20k GitHub starsUsed in 1 repo~756 tokens
    Agent WorkflowsAuto-check passed
  • Task Observer

    rebelytics/one-skill-to-rule-them-all

    Monitors task execution for skill improvement opportunities.

    3.2k GitHub starsUsed in 1 repo~12k tokens
    Agent WorkflowsAuto-check passed
  • O2 Review Loop

    openobserve/openobserve

    Splits a change into planner, coder and independent reviewer roles: you confirm a spec, a subagent implements it, and a separate reviewer checks each round's local WIP commit.

    22k GitHub stars~3.7k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from BlackBeltTechnology/pi-agent-dashboard

All 66 skills in this repo
  • Browser

    BlackBeltTechnology/pi-agent-dashboard

    Browser automation via the agent-browser CLI. An agent skill from BlackBeltTechnology/pi-agent-dashboard.

    315 GitHub starsUsed in 1 repo~2k tokens
    Auto-check passed
  • Pi Dashboard

    BlackBeltTechnology/pi-agent-dashboard

    Monitor and control the pi-dashboard server. An agent skill from BlackBeltTechnology/pi-agent-dashboard.

    315 GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed
  • CI Troubleshoot

    BlackBeltTechnology/pi-agent-dashboard

    Diagnose failed GitHub Actions runs for pi-agent-dashboard: the 11-file workflow taxonomy, affected-test selection, the release pipeline, known failure modes, and how to read gh run logs and…

    315 GitHub stars~3.5k tokensUpdated today
    Auto-check passed
  • Debug Dashboard

    BlackBeltTechnology/pi-agent-dashboard

    Diagnose problems in the running pi-agent-dashboard system: server.log, /api/health, bridge WebSocket connectivity, vitest triage, known-issue FAQ entries.

    315 GitHub stars~1.6k tokensUpdated today
    Auto-check passed
  • Implement

    BlackBeltTechnology/pi-agent-dashboard

    Disciplined implementation in pi-agent-dashboard: the rebuild matrix (extension→reload, server→restart, client→build+restart, openspec-apply→full rebuild) plus the project's code discipline rules.

    315 GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Session To Guideline

    BlackBeltTechnology/pi-agent-dashboard

    Turn a pi session into a Markdown "how-we-did-it" collaboration guideline: reads the session's JSONL transcript and synthesizes a reusable playbook of which prompts worked, what had to be steered…

    315 GitHub stars~3.2k tokensUpdated today
    Auto-check passed

Categories

Questions about Reverse Spec From Code

What does Reverse Spec From Code do?

Reverse-generate OpenSpec capability specs (openspec/specs/<cap/spec.md) from code that lacks them, or reconcile an existing stale spec with --refresh, using parallel subagents. Reverse Spec From Code is an agent skill from BlackBeltTechnology/pi-agent-dashboard.md) from code that lacks them, or reconcile an existing stale spec with --refresh, using parallel subagents.

When should I use Reverse Spec From Code?

Reverse Spec From Code fits situations like: tasks that involve Subagents.

How do I install Reverse Spec From Code in Claude Code?

Run `npx skills add BlackBeltTechnology/pi-agent-dashboard --skill reverse-spec-from-code -a claude-code`. Or copy the skill folder (packages/openspec-workflow/.pi/skills/reverse-spec-from-code in BlackBeltTechnology/pi-agent-dashboard) into .claude/skills/reverse-spec-from-code in your project. Claude Code loads it when a task matches its description.

How do I install Reverse Spec From Code in Codex?

Run `npx skills add BlackBeltTechnology/pi-agent-dashboard --skill reverse-spec-from-code -a codex`. Or copy the skill folder (packages/openspec-workflow/.pi/skills/reverse-spec-from-code in BlackBeltTechnology/pi-agent-dashboard) into .agents/skills/reverse-spec-from-code in your project. Codex loads it when a task matches its description.

Can I use Reverse Spec From Code in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add BlackBeltTechnology/pi-agent-dashboard --skill reverse-spec-from-code -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/reverse-spec-from-code, .gemini/skills/reverse-spec-from-code, .github/skills/reverse-spec-from-code and .opencode/skills/reverse-spec-from-code in your project.

What does Reverse Spec From Code need to run?

SKILL.md names no scripts, command-line tools or credentials: Reverse Spec From Code is instructions for the agent only.

Does Reverse Spec From Code access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Reverse Spec From Code safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Reverse Spec From Code use?

Reverse Spec From Code is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Reverse Spec From Code use?

About 2.4k tokens (SKILL.md is roughly 9.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Reverse Spec From Code?

Skills that share tags, products or a category with Reverse Spec From Code: Claude Code Agent Development (anthropics/claude-plugins-official, 38k stars), Subagent Driven Development (Asvarox/allkaraoke, 261 stars), Dispatching Parallel Agents (ultralisp/ultralisp, 258 stars) and Paseo Advisor Second Opinion (getpaseo/paseo, 20k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Reverse Spec From Code?

BlackBeltTechnology (a GitHub organization) maintains it in BlackBeltTechnology/pi-agent-dashboard, which has 315 GitHub stars. The repository holds 66 skills in this directory. The repository was last updated on October 8, 2026.

Source: BlackBeltTechnology/pi-agent-dashboard on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.