AgentSkillsCN

gap-analysis

在代码中寻找潜在的漏洞、空缺、断裂的工作流,以及尚未完善的特性。在功能落地之前(用于发掘隐性需求),或在代码审计过程中(用于查找TODO、FIXME、空置的处理逻辑、断裂的工作流),此技能都大有可为。关键词包括:差距分析、代码审计、寻找空缺、不完整、工作流断裂。

SKILL.md
--- frontmatter
name: gap-analysis
description: Find gaps, stubs, broken workflows, and incomplete features in code. Use before implementing features (to find implicit requirements) or for code audits (to find TODO, FIXME, empty handlers, broken workflows). Keywords - gap analysis, audit, find stubs, incomplete, broken workflow.

GAP Analysis

Find implicit requirements and incomplete code. 90% of AI failures are due to specification gaps.

Mode A: Planning (Before Implementation)

Step 1: Explicit Requirements

markdown
## EXPLICIT REQUIREMENTS
**Task:** [one sentence]
**What's specified:**
- [ ] [requirement 1 -- quote]
- [ ] [requirement 2 -- quote]
**Constraints:** [limitations]

Step 2: Fit-Gap Analysis

Check each category:

CategoryQuestionsExample Gaps
DataFormats? Null/empty? Boundaries?max length, encoding, special chars
UXLoading state? Error state? Empty state?skeleton, retry button, placeholder
IntegrationWhat else affected? Side effects?cache invalidation, events
SecurityAccess rights? Validation?authorization, input sanitization
PerformanceData volume? Pagination?batch limits, timeouts
ErrorsWhat if fails? Retry?graceful degradation, error messages

Step 3: Pre-mortem

Ask: "A week passed, the feature broke. Why?"

  • Missed edge case (empty data, null, large volumes)
  • Uncovered error scenario (API unavailable, timeout)
  • Forgot state handling (loading, error, empty)
  • Didn't check access rights
  • Didn't test mobile/responsive

Step 4: Report

markdown
## GAP ANALYSIS REPORT

### Category: [DATA/UX/ERRORS/etc]
| # | GAP | Severity | Action |
|---|-----|----------|--------|
| 1 | [description] | HIGH/MED/LOW | [what to do] |

### TOTALS:
- HIGH (blockers): [count]
- MED (desirable): [count]
- LOW (later): [count]

For HIGH gaps -- ASK user, don't assume!

Mode B: Codebase Scan

Run scan script for automated detection:

bash
bash .cursor/skills/gap-analysis/scripts/scan-gaps.sh

Manual checks:

CheckHow to findGAP if
Buttons without actionsonClick={() => {}}Button does nothing
Forms without submitonSubmit missing or emptyForm doesn't send data
Links to nowherehref="#" or href=""Link leads nowhere
Loading without timeoutisLoading without error boundaryMay hang forever
Error without recoverycatch {} emptyError swallowed
Partial CRUDCreate exists but no Update/DeleteIncomplete

Business Logic

markdown
## FEATURE COMPLETENESS
| Feature | Create | Read | Update | Delete | Status |
|---------|--------|------|--------|--------|--------|
| [Entity] | ok/no | ok/no | ok/no | ok/no | COMPLETE/INCOMPLETE |

GAP Severity

SeverityCriteriaAction
HIGHWithout it, feature doesn't workBLOCKER -- fix before implementation
MEDWorks but bad UX/qualityFix during implementation
LOWNice-to-haveBacklog or ask user

Key Principle

Before creating a new feature:

  1. rg "X" -- maybe it already exists?
  2. rg "TODO.*X" -- maybe there's a stub?
  3. Check UI -- maybe button exists but doesn't work?

If found stub -> COMPLETE existing, don't create new!