Install
openclaw skills install @afonsoft/gap-analysisUse when auditing a repository for evidence-backed gaps between code, SPECs, architecture, and documentation — before a release, after a review, or when the user asks what is missing or divergent. Confirmed gaps become Draft SPECs via write-specs, a tracked GitHub Epic via create-issues, and orchestrated execution via orchestrator, with an explicit approval gate before any external action.
openclaw skills install @afonsoft/gap-analysisAudit 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.
orchestrator 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} (label epic) summarizing the audit, with the gap list and links.slice), linked to the Epic and to its SPEC path; dependencies via Blocked by with real Issue numbers.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 epic/slice per create-issues; 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)write-specs — produces the per-gap SPEC SDDcreate-issues — publishes the Epic + slice Issuesorchestrator — validates and executes approved SPECsimprove-codebase-architecture — complementary P2 architecture deepening analysis