Skip to content

Audit Spec

Ali Sadeghi edited this page Jan 20, 2026 · 2 revisions

Audit Spec

Audits, generates, or compares specifications for existing KMP features.

Usage:

# Generate spec from existing code
/audit-spec login

# Compare existing spec with implementation (drift detection)
/audit-spec login --compare

When to Use

Scenario Use This? Instead Use
Legacy feature without spec Yes -
Check spec-code consistency Yes (--compare) -
New feature creation No creating-kmp-feature skill
Modifying existing feature No modifying-kmp-feature skill

Note: For SDD best practices, specs should be written BEFORE implementation. This command is for auditing existing code or documenting legacy features.

Mode 1: Generate Spec (Default)

  1. Analyzes feature implementation in feature/{name}/
  2. Extracts models, API contracts, state management, navigation
  3. Checks for existing PRD to preserve rationale/WHY sections
  4. Generates comprehensive specification
  5. Saves to .claude/docs/{name}/spec.md

Output Includes

  • Metadata with version tracking
  • Goals and Non-Goals (TODO if not from PRD)
  • Background & Rationale (from PRD or TODO)
  • Design Decisions (from PRD or TODO)
  • Data models with field descriptions
  • API endpoints and contracts
  • State management patterns
  • Navigation routes and callbacks
  • Test scenarios

Mode 2: Drift Detection (--compare)

Compares existing spec with current implementation:

/audit-spec login --compare

Output Includes

  • Summary of sync status by category
  • Detailed drift findings with file locations
  • Proposed spec updates in diff format
  • Action checklist

Example Drift Report

## Spec Drift Report: login

| Category | Status |
|----------|--------|
| Data Models | ⚠️ 1 drift |
| State Management | ✅ In sync |

### Data Models Drift
**File:** `LoginDto.kt:15`

| Aspect | Spec Says | Code Has |
|--------|-----------|----------|
| Fields | 3 fields | 4 fields |

**Missing from spec:**
```kotlin
val rememberMe: Boolean

## Example Generated Spec

```markdown
# Login Specification

## Metadata
| Field | Value |
|-------|-------|
| Version | 1.0.0 |
| Status | Active |

## Purpose
User authentication with email/password login.

## Goals
- Enable secure user authentication
- Support remember me functionality

## Non-Goals
- Social login (future)
- Biometric authentication (future)

## Data Models
- LoginRequest: email, password, rememberMe
- LoginResponse: token, user

## State Management
- LoginUiState: Uninitialized | Loading | Success | Failed

## Navigation
- LoginRoute → onLoginSuccess: () -> Unit

Back to Commands

Clone this wiki locally