reverse-spec-from-code

reverse-spec-from-code is a skill for Claude Code, Codex from BlackBeltTechnology/pi-agent-dashboard. It costs 91 tokens per session (2,419 once invoked), scanned C, original, MIT.

A tool that creates OpenSpec capability specifications from existing code. It can also refresh a specification when the code and its documented behavior have drifted apart.

In plain words
What is it for?
Use it to generate or refresh behavioral specs for packages, review them against the code, and promote confirmed specs into the project's specification directory.
Why use it?
It helps document code that lacks reliable specifications and checks generated descriptions against the implementation to reduce made-up behavior.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions subagents; mentions AGENTS.md.

Good fit Use it to generate or refresh behavioral specs for packages, review them against the code, and promote confirmed specs into the project's specification directory.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/blackbelttechnology/pi-agent-dashboard/reverse-spec-from-code
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add BlackBeltTechnology/pi-agent-dashboard --skill reverse-spec-from-code
Clone the repo
git clone --depth 1 https://github.com/BlackBeltTechnology/pi-agent-dashboard

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for reverse-spec-from-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/blackbelttechnology/pi-agent-dashboard/reverse-spec-from-code/github.svg)](https://agentmods.dev/skills/blackbelttechnology/pi-agent-dashboard/reverse-spec-from-code)
Your own site
<a href="https://agentmods.dev/skills/blackbelttechnology/pi-agent-dashboard/reverse-spec-from-code"><img src="https://agentmods.dev/badge/skills/blackbelttechnology/pi-agent-dashboard/reverse-spec-from-code/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for reverse-spec-from-code

Your own site · 80×15
<a href="https://agentmods.dev/skills/blackbelttechnology/pi-agent-dashboard/reverse-spec-from-code"><img src="https://agentmods.dev/badge/skills/blackbelttechnology/pi-agent-dashboard/reverse-spec-from-code.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 91 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,419 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00091 $0.02419
Opus 5 $0.00046 $0.01210
Sonnet 5 $0.00018 $0.00484
Haiku 4.5 $0.00009 $0.00242

Measured 6d ago against content hash d879e801f704, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade C, and why

reverse-spec-from-code scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf "$d"
packages/openspec-workflow/.pi/skills/reverse-spec-from-code/SKILL.md · 185 lines

How it starts

The opening of the file, as written. The whole thing — 185 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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.

Read the full file on GitHub · 185 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 185 lines · 91 tokens per session scan C d879e801f704

Subscribe to this mod's changes

reverse-spec-from-code is a skill published in the GitHub repository BlackBeltTechnology/pi-agent-dashboard (278 stars, last pushed today), licensed MIT. It adds 91 tokens to every session and 2,419 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.