Skip to content
story-extract logo

Examine the primary file

story-extract

Load when code exists but no spec does — reverse-engineering story documentation from an existing implementation. Use for brownfield stories, code written before Speck was adopted, or when a feature was built without going through the spec flow. FIRST ACTION after loading: read both templates — ....

telum-ai/speck0installs2stars

SKILL.md

Full skill instructions

The user input to you can be provided directly by the agent or as a command argument - you MUST consider it before proceeding with the prompt (if not empty).

User input:

$ARGUMENTS

⚠️ Step 0: Read Templates First

Before any other action — read BOTH templates now using the Read tool:

.speck/​templates/​story/​story-template.md
.speck/​templates/​story/​codebase-scan-template.md

This skill produces two artifacts. The first template defines spec.md structure; the second defines codebase-scan-extracted.md structure. Reading both first shapes what you extract from the existing code.

Checkpoint: After reading both, note each template's top-level sections. Then continue to Step 1.

Extract story-level specifications from existing code.

Context Requirements

Establish the hierarchy:

  • Project identification
  • Epic identification
  • Code location or specific features

Ask if not provided:

  • "Which epic should I extract stories from?"
  • "Any specific code areas to focus on?"

Step 1: Code Area Analysis

Identify Story Boundaries

Look for natural story indicators:

Frontend Indicators:

  • Page components
  • Form implementations
  • UI features
  • User interactions

Backend Indicators:

  • API endpoints
  • Business operations
  • Database transactions
  • Background jobs

Full-Stack Indicators:

  • Complete user workflows
  • Feature flags
  • Test suites
  • Documentation sections

Size Assessment

Determine if code represents:

  • Single story (one user goal)
  • Multiple stories (several goals)
  • Partial story (incomplete feature)
  • Epic-level scope (too large)

Step 2: Story Extraction Process

For each identified story area:

Code Comprehension

# Examine the primary file
cat [FILE_PATH] | grep -E "function|class|export|def" | head -20

# Find related files
grep -r "[FUNCTION_NAME]" [PROJECT_PATH] --include="*.{js,ts,py,java,go}" | grep -v node_modules

# Look for tests
find [PROJECT_PATH] -name "*test*" -o -name "*spec*" | xargs grep -l "[FEATURE_NAME]"

# Check for documentation
grep -r "[FEATURE_NAME]" [PROJECT_PATH] --include="*.md" 

Extract Story Components

User Story Format: From code behavior, infer:

  • Who: User type from auth checks, routes
  • What: Action from function names, endpoints
  • Why: Business value from comments, docs

Acceptance Criteria: From implementation, extract:

  • Input validation rules
  • Business logic conditions
  • Output format/​behavior
  • Error handling cases

Technical Details: Document what exists:

  • API endpoints used
  • Database operations
  • External integrations
  • UI components

Step 3: Generate Story Specifications

Create story structure:

mkdir -p specs/​projects/[PROJECT_ID]/​epics/[EPIC_ID]/​stories/[STORY_ID]-[story-name]

Generate the story artifacts using existing Speck templates (this command does NOT have its own output template).

  1. Generate spec.md (WHAT/​WHY) using the story spec template:
  • Load and follow the template exactly: .speck/​templates/​story/​story-template.md
  • Populate from observed behavior in code/​tests/​docs
  • Mark uncertain inferences as: [NEEDS CLARIFICATION: ...]
  • Do not include deep implementation details, schemas, or file-by-file inventories here (those belong in the scan report)
  1. Generate codebase-scan-extracted.md (HOW/​WHERE evidence) using the scan template:
  • Load and follow the template exactly: .speck/​templates/​story/​codebase-scan-template.md
  • Capture:
    • Primary files and entry points
    • Routes/​endpoints, data models, and integration points (if relevant)
    • Observed validation/​error handling patterns
    • Test locations + missing tests
    • Notable technical debt / anti-patterns discovered

Traceability markers:

  • Use [FROM SCAN] for facts derived directly from code reading/​search
  • Use [INFERRED] for inferred behavior not directly verified

Step 4: Bulk Story Extraction

For extracting multiple stories:

Batch Analysis

# Find all endpoints in a router
grep -E "get\(|post\(|put\(|delete\(" [ROUTER_FILE]

# Find all page components
find [PAGES_DIR] -name "*.jsx" -o -name "*.tsx" | grep -v test

# Find all service methods
grep -E "async|function|def" [SERVICE_FILE] | grep -v private

Story Grouping

Group related code into stories:

  • CRUD operations → Separate stories
  • Multi-step workflows → Single story
  • Variations → Story with conditions

Batch Generation

Create multiple story specs efficiently:

  1. Identify all story candidates
  2. Generate specs in batch
  3. Mark for review
  4. Create extraction report

Step 5: Extraction Report

Return an extraction summary as command output (do not introduce a new “report template” doc).

Include:

  • Epic + code scope analyzed
  • Story directories created/​updated
  • Per-story status: Complete / Partial / Unknown + confidence
  • Biggest gaps/​questions needing human clarification
  • Recommended next command(s): /​story-clarify, /​story-plan, /​story-validate, or follow-up scan

Step 6: Interactive Review

Present extraction results:

  • "I've extracted [N] stories from your codebase"
  • "Found [X] complete, [Y] partial implementations"
  • "Several areas need clarification..."

Ask for validation:

  • "Do these story boundaries make sense?"
  • "Are the extracted rules correct?"
  • "What's the history behind [partial feature]?"

Step 7: Guide Next Steps

Based on extraction:

If mostly complete:

  • "Your epic is well-implemented!"
  • "Consider /​story-validate for quality check"
  • "Document any undocumented features"

If many gaps:

  • "Several stories need completion"
  • "Consider /​story-plan for missing pieces"
  • "Consider /​story-scan for a deep, HIGH-confidence implementation guide before planning"
  • "Prioritize based on user value"

If messy code:

  • "Refactoring needed before new features"
  • "Consider technical debt epic"
  • "Plan incremental improvements"

Extraction Patterns

Well-Documented Code

  • High confidence in extraction
  • Clear story boundaries
  • Business rules evident

Test-Driven Code

  • Extract stories from test names
  • Acceptance criteria from test cases
  • High confidence in behavior

Legacy Code

  • Lower confidence
  • Focus on behavior, not structure
  • More clarification needed

Prototype Code

  • Many gaps expected
  • Focus on intent
  • Plan production implementation

Success Criteria

Successful extraction:

  • ✅ All implemented features documented
  • ✅ Story boundaries make sense
  • ✅ Technical debt identified
  • ✅ Team validates accuracy
  • ✅ Clear path forward

More skills from telum-ai

project-brainstorm logo
telum-ai/speck

project-brainstorm

Load when a user has a vague idea, problem, or inspiration but isn't sure what to build. Use before /project-specify when the project concept needs crystallizing from loose thoughts into something concrete.

2 0
View

Load when using Docker for containerizing applications. Applies when creating Dockerfiles, docker-compose setups, multi-stage builds, or optimizing container images.

2 0
View
visual-quality logo
telum-ai/speck

visual-quality

Enforce visual design quality in every UI file. Fires for .tsx, .jsx, .vue, .svelte, and similar component files. Ensures implementations express the project's design personality rather than producing generic/boilerplate UI.

2 0
View
project-clarify logo
telum-ai/speck

project-clarify

Load after project.md exists to fill gaps through targeted Q&A. Use when project goals, target users, or scope feel underspecified. Run before project-context or project-architecture to prevent rework downstream.

2 0
View
story-outline logo
telum-ai/speck

story-outline

DEPRECATED in Speck v7. Use /speck-skeptical-review + /speck-decision-log instead — they replace outline-style research mapping with structured alternative enumeration and decision locking. /story-plan now performs just-in-time research inline. This skill remains for v6 compatibility but redirect...

2 0
View

Load when building offline-first applications that work without network connectivity. Applies when implementing local storage, sync queues, conflict resolution, or background sync.

2 0
View
project-constitution logo
telum-ai/speck

project-constitution

Load (Platform play level only) to define technical principles and architectural guardrails for the project. Produces constitution.md — optional but valuable when a team needs explicit coding standards, governance rules, or non-negotiable constraints. FIRST ACTION after loading: read template at ...

2 0
View
posthog-integration logo
telum-ai/speck

posthog-integration

Load when integrating PostHog for product analytics and feature flags. Applies when implementing event tracking, A/B testing, session replay, or funnel analysis.

2 0
View
project-validate logo
telum-ai/speck

project-validate

Load when all epics are validated and /audit has run for the project. Verifies the project meets its original vision and product-contract.md paid promise. Runs end-to-end JTBD smoke test via /larp across all personas. Declares a project-level readiness state. Produces project-validation-report.md...

2 0
View
story-scan logo
telum-ai/speck

story-scan

Load for brownfield stories where existing code must be understood before planning. Use when a story extends, modifies, or integrates with significant existing functionality. Produces codebase-scan.md — skip for fully greenfield stories. FIRST ACTION after loading: read template at .speck/templat...

2 0
View

Load when building serverless applications with AWS Lambda, Vercel Functions, or Cloudflare Workers. Applies when implementing FaaS patterns, managing cold starts, or optimizing serverless costs.

2 0
View
epic-analyze logo
telum-ai/speck

epic-analyze

Load after epic-tech-spec.md and epic-breakdown.md exist — quality check for consistency and completeness before any story work begins. Catches spec drift and missing coverage between the tech spec and story breakdown. FIRST ACTION after loading: read template at .speck/templates/epic/epic-analys...

2 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View