dceoy

speckit-baseline

9
0
# Install this skill:
npx skills add dceoy/speckit-agent-skills --skill "speckit-baseline"

Install specific skill from multi-skill repository

# Description

Generate feature specifications by analyzing existing source code.

# SKILL.md


name: speckit-baseline
description: Generate feature specifications by analyzing existing source code.


Spec Kit Baseline Skill

When to Use

  • You need a spec for existing or legacy code.
  • You want to document a feature before refactoring.
  • You inherited a codebase without written requirements.

Inputs

  • A target path, file list, or glob pattern describing the code to analyze.
  • Repo context with .specify/ scripts and templates.

If the target is missing or ambiguous, ask a focused question before continuing.

Goal

Generate a technology-agnostic spec for existing code, then create the feature branch/spec file using the standard Spec Kit templates.

Workflow

  1. Parse target input: Identify files, directories, or patterns to analyze.
  2. Accept file paths, glob patterns, or directory paths.
  3. If empty: stop and ask for a concrete target.

  4. Discover and read source files:

  5. Expand globs to a file list.
  6. Read file contents for analysis.
  7. Identify primary language(s) and frameworks.
  8. Map key file relationships and dependencies.

  9. Analyze code structure:

  10. Identify entry points and public interfaces.
  11. Extract function/method signatures and behaviors.
  12. Find data models and entities.
  13. Detect API endpoints and routes.
  14. Identify user-facing functionality.

  15. Generate a short name (2-4 words) from the analyzed code:

  16. Use action-noun format (e.g., "user-auth", "payment-processing").
  17. Base on primary functionality discovered.
  18. Preserve technical terms where meaningful.

  19. Create the feature branch and spec file:

  20. Find the highest existing feature number for this short name (branches/specs).
  21. Run .specify/scripts/bash/create-new-feature.sh --json with the calculated number and short name.
  22. Read BRANCH_NAME, FEATURE_DIR, and SPEC_FILE paths from the script JSON output.
  23. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").

  24. Load the spec template from .specify/templates/spec-template.md.

  25. Draft the specification using the template structure:

  26. User Stories: Infer from user-facing code paths and interactions.
  27. Acceptance Scenarios: Derive from validation logic, error handling, and tests.
  28. Functional Requirements: Extract from business rules and constraints.
  29. Key Entities: Identify from data models and schemas.
  30. Success Criteria: Infer from metrics, logging, or performance-related code.
  31. Assumptions: Document inferences made during analysis.

  32. Abstract implementation details:

  33. Convert technical patterns to user-focused requirements.
  34. Remove framework-specific terminology.
  35. Focus on WHAT the code does, not HOW it does it.

  36. Create spec quality checklist at FEATURE_DIR/checklists/requirements.md.

  37. Report completion with:

    • Branch name and spec file path.
    • Summary of analyzed files.
    • Key features discovered.
    • Areas needing clarification or review.

Outputs

  • specs/<feature>/spec.md
  • specs/<feature>/checklists/requirements.md

Key rules

  • Focus on extracting WHAT and WHY from HOW.
  • Abstract away implementation details in the generated spec.
  • Document assumptions made during code analysis.
  • Flag areas where code behavior is unclear.
  • Preserve discovered business rules and constraints.
  • Use [NEEDS CLARIFICATION] for ambiguous code sections (max 3).
  • Generated specs should be validated by someone who knows the feature.

Examples

Code Pattern → Spec Requirement:

  • if (user.role === 'admin') → "System MUST restrict action to administrator users"
  • password.length >= 8 → "Passwords MUST be at least 8 characters"
  • cache.set(key, value, 3600) → "System MUST cache results for improved performance"
  • try { ... } catch (e) { notify(e) } → "System MUST notify users when errors occur"

Code Pattern → User Story:

  • Login endpoint with OAuth → "As a user, I can sign in using my social account"
  • Shopping cart logic → "As a customer, I can add items to my cart for later purchase"
  • Report generation → "As an analyst, I can generate reports on system activity"

Next Steps

After generating spec.md:

  • Clarify with domain experts using speckit-clarify.
  • Plan modernization/refactoring with speckit-plan.
  • Compare the generated spec with actual requirements to identify gaps.

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.