/spec-driven:gap-analysis runs instead · from spec-driven
Audits a repository for evidence-backed gaps between code, specs, architecture, and documentation. Converts confirmed gaps into SPECs, GitHub Issues, and orchestrated delivery with an explicit approval gate.
This skill never runs in Claude Code
It ships in spec-driven at skills/, but /spec-driven:gap-analysis (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
Audit a repository's current state (AS-IS) against its documented desired state (TO-BE) and turn evidence-backed gaps into SPECs, GitHub Issues, and orchestrated delivery.
Every conclusion must cite reproducible evidence: file paths, line ranges, symbols, commands, test output, specs, issues, or commits. A missing source is itself evidence — record it, never invent content to compensate for it.
All questions and confirmations directed at the user must be in Portuguese (pt-BR). Internal reasoning, records, and documentation are in English.
architecture (on behalf of orchestrator in Phase 5) as the final evidence-backed audit before documentation sync./diagnose./improve-codebase-architecture.write-specs, create-issues, or orchestrator — this skill delegates to them per their real contracts.<redacted>) instead.gh), missing skill, or missing directory blocks only the affected phase — record it and keep going elsewhere.Audit these sources when they exist. Record each as present or absent in the report:
| Source | What it provides |
|---|---|
.specs/SPEC-*.md | Approved/desired state (TO-BE): requirements, acceptance criteria |
docs/ | User-facing and technical documentation (TO-BE) |
docs/architecture/ | ADRs and diagrams — architectural TO-BE |
.claude/CONTEXT.md | Domain language and project context |
.claude/MEMORY.md, .claude/memory/ | Cross-session state, prior decisions, previous audit runs |
CLAUDE.md, AGENTS.md, README.md | Harness rules, official commands, conventions |
.claude/rules/, .claude/agents/, rules files | Local guardrails and precedence |
| Source code + build configs | AS-IS implementation |
| Tests, linters, analyzers, CI pipelines, hooks | Existing coverage and enforcement |
| Git history and open/closed GitHub Issues | Recent work, known gaps, dedup targets |
| Installed skills | Existing automation that may already cover a gap |
Run scripts/collect-sources.sh for the mechanical part of this inventory (presence/absence, git state, gh auth, build manifests) — then read what exists.
Rules precedence: repository-local rules (AGENTS.md, CLAUDE.md, .claude/rules/) override generic assumptions. Detect monorepos and submodules (git submodule status, workspace manifests); keep per-module inventories and Issue ownership separate.
git status --porcelain, remotes, and submodules.gh auth status and gh repo view — required only for the Issues phase; record the result now.write-specs, create-issues, orchestrator) and read their current SKILL.md. If one is missing, block only its phase and report an actionable diagnostic.Build a matrix with one row per topic area:
| Topic | AS-IS (code/tests/config) | TO-BE (specs/docs/rules) | Sources |
|---|
Distinguish fact (observed), interpretation (inferred), and [A DEFINIR] (unknown). Every TO-BE entry names its source document — undocumented desired state is not a valid TO-BE.
Generate candidates across these categories:
requirements · architecture · implementation · tests · security · observability · documentation · automation · operation
A candidate needs a desired state, a current state, and a plausible difference. Record each using references/gap-record.md.
Test every candidate against existing coverage before calling it a gap: compiler/type checker, linters and static analyzers, functional and architecture tests, CI pipelines, hooks, review gates, documentation that already describes the behavior, and installed automation.
Emit exactly one verdict per candidate:
| Verdict | Meaning |
|---|---|
CONFIRMADO | Real difference, no existing coverage — actionable gap |
REJEITADO | Already covered, or difference not proven — cite the covering evidence |
DUPLICADO | Equivalent spec, Issue, or mechanism exists — link it, create nothing |
INCONCLUSIVO | Contradictory or insufficient evidence — ask the user, never pick silently |
Score each CONFIRMADO gap qualitatively — impact, urgency, risk, scope, effort, confidence — with a one-line justification each (rubric in references/gap-record.md). Never fabricate metrics.
Assign the stable key GAP-<category>-<kebab-scope> and dedupe against .specs/, Issue titles/labels/bodies (gh issue list --state all), and prior runs in .claude/memory/gap-analysis-*.md. Decompose any gap too broad for a single spec before continuing.
For each CONFIRMADO, non-duplicate gap, invoke the write-specs skill per its own contract: hand it the collected evidence (AS-IS, TO-BE, verdict, priority, scope) as the starting point of its design tree and let it run its pt-BR interview. The result is one .specs/SPEC-{YYYYMMDD}-{slug}.md in Draft per gap, referencing the gap key in the Ticket/metadata.
When all Draft SPECs exist, present a pt-BR summary and STOP:
Análise de gaps concluída.
- Candidatos: [N] | Confirmados: [N] | Rejeitados: [N] | Duplicados: [N] | Inconclusivos: [N]
- SPECs Draft gerados: [lista de paths]
Aprovar os SPECs e criar as Issues no GitHub? (sim/não)
No Issue, branch, commit, push, PR, or spec execution before an explicit sim.
After approval, invoke create-issues per its contract:
gap-analysis-{YYYYMMDD} (labels epic + todo) summarizing the audit, with the gap list and links.slice + todo), linked to the Epic and to its SPEC path; dependencies via Blocked by with real Issue numbers. Status labels follow the Label Contract in create-issues.Only when every approved SPEC has an Issue (or valid link), invoke orchestrator per its contract — it reconciles and executes approved SPECs through its own Phase 4–5 loop (build, tests, lint, review, QA). Verify first: clean working tree, branch policy, spec Status: Approved, dependency order.
Any failed validation → report failure with evidence; never declare success without green build/test output.
The orchestrator executes all approved SPECs in
.specs/, not only the ones from this run — this is by design.
Write the consolidated report to .claude/memory/gap-analysis-{YYYYMMDD}.md using references/report-template.md: source inventory, candidates with verdicts, priorities, spec paths, Issue links, orchestrator outcome, and open pendencies. This file doubles as the resume state for idempotent re-runs.
GAP-<category>-<kebab-scope>; a gap already mapped to a spec or Issue is DUPLICADO, never recreated..claude/memory/gap-analysis-*.md and resume from the last confirmed phase.| Mistake | Fix |
|---|---|
| Promoting "I didn't find it" to a gap | Prove TO-BE + AS-IS + impact with evidence first. |
| Flagging something a test or linter already covers | Check coverage before the verdict; mark REJEITADO with the covering evidence. |
| Creating Issues before the gate | The gate is hard: no external action without explicit approval. |
| Inventing labels, milestones, or assignees | Use only the canonical kind/status labels per the create-issues Label Contract; anything else needs proof it exists. |
| Hiding rejected or inconclusive candidates | Report every verdict — rejections are part of the audit's value. |
| Silently picking a side in contradictory docs | Mark INCONCLUSIVO and ask the user. |
| Copying a secret into evidence to prove a point | Reference path:line with <redacted> — never the value. |
| Evaluating people | Analyze artifacts and process only. |
references/gap-record.md — candidate record, verdict rules, priority rubricreferences/report-template.md — consolidated report / resume state formatscripts/collect-sources.sh — mechanical source inventory (read-only)architecture — caller in Phase 5; hands off delivery context and consumes the audit outcomewrite-specs — produces the per-gap SPEC SDDcreate-issues — publishes the Epic + slice Issuesorchestrator — validates and executes approved SPECsimprove-codebase-architecture — complementary P2 architecture deepening analysisWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
27 skills in this plugin
/architectureSingle owner of everything under docs/architecture/ — ADRs, architecture and design documents, and architecture diagrams. Routes each deliverable to the right engine: /mermaid-architecture for Markdown-native diagrams, /drawio-architecture for editable .drawio diagrams, and the optional archify skill for interactive standalone HTML diagrams (used only when already installed in the environment; never installed at runtime). Use whenever architecture documentation, ADRs, or architecture diagrams must be created or updated./building-mcp-serversUse when building a new MCP server in TypeScript, Python, or C# that exposes tools to LLMs./code-review-and-qualityUse when reviewing code before it merges, whether written by an agent or a human./composio-mcpUse when the user asks to connect an AI agent to external apps via Composio, or when Composio CLI or MCP setup fails./create-agent-harnessUse when initializing or migrating an AI agent harness in a repository./create-issuesUse when turning approved plans, specs, PRDs, or Epics into trackable GitHub Issues.npx claudepluginhub afonsoft/skills --plugin spec-drivenOther plugins' skills for the same job