Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 19 additions & 85 deletions .cursor/commands/specfact.01-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,110 +10,44 @@ You **MUST** consider the user input before proceeding (if not empty).

## Purpose

Import an existing codebase into a SpecFact plan bundle. Analyzes code structure using AI-first semantic understanding or AST-based fallback to generate a plan bundle representing the current system.

**When to use:**

- Starting SpecFact on an existing project (brownfield)
- Converting legacy code to contract-driven format
- Creating initial plan from codebase structure

**Quick Example:**

```bash
/specfact.01-import --bundle legacy-api --repo .
```
Import codebase → plan bundle. CLI extracts routes/schemas/relationships/contracts. LLM enriches context/"why"/completeness.

## Parameters

### Target/Input

- `--bundle NAME` (required argument) - Project bundle name (e.g., legacy-api, auth-module)
- `--repo PATH` - Repository path. Default: current directory (.)
- `--entry-point PATH` - Subdirectory for partial analysis. Default: None (analyze entire repo)
- `--enrichment PATH` - Path to LLM enrichment report. Default: None

### Output/Results

- `--report PATH` - Analysis report path. Default: .specfact/reports/brownfield/analysis-<timestamp>.md

### Behavior/Options

- `--shadow-only` - Observe without enforcing. Default: False
- `--enrich-for-speckit` - Auto-enrich for Spec-Kit compliance. Default: False

### Advanced/Configuration

- `--confidence FLOAT` - Minimum confidence score (0.0-1.0). Default: 0.5
- `--key-format FORMAT` - Feature key format: 'classname' or 'sequential'. Default: classname
**Target/Input**: `--bundle NAME` (optional, defaults to active plan), `--repo PATH`, `--entry-point PATH`, `--enrichment PATH`
**Output/Results**: `--report PATH`
**Behavior/Options**: `--shadow-only`, `--enrich-for-speckit`
**Advanced/Configuration**: `--confidence FLOAT` (0.0-1.0), `--key-format FORMAT` (classname|sequential)

## Workflow

### Step 1: Parse Arguments

- Extract `--bundle` (required)
- Extract `--repo` (default: current directory)
- Extract optional parameters (confidence, enrichment, etc.)

### Step 2: Execute CLI
1. **Execute CLI**: `specfact import from-code [<bundle>] --repo <path> [options]`
- CLI extracts: routes (FastAPI/Flask/Django), schemas (Pydantic), relationships, contracts (OpenAPI scaffolds), source tracking
- Uses active plan if bundle not specified

```bash
specfact import from-code <bundle-name> --repo <path> [options]
```
2. **LLM Enrichment** (if `--enrichment` provided):
- Read `.specfact/projects/<bundle>/enrichment_context.md`
- Enrich: business context, "why" reasoning, missing acceptance criteria
- Validate: contracts vs code, feature/story alignment

### Step 3: Present Results

- Display generated plan bundle location
- Show analysis report path
- Present summary of features/stories detected
3. **Present**: Bundle location, report path, summary (features/stories/contracts/relationships)

## CLI Enforcement

**CRITICAL**: Always use SpecFact CLI commands. See [CLI Enforcement Rules](./shared/cli-enforcement.md) for details.

**Rules:**

1. **ALWAYS execute CLI first**: Run `specfact import from-code` before any analysis
2. **ALWAYS use non-interactive mode for CI/CD**: Use `--no-interactive` flag in Copilot environments
3. **NEVER modify .specfact folder directly**: All operations must go through CLI
4. **NEVER create YAML/JSON directly**: All artifacts must be CLI-generated
5. **Use CLI output as grounding**: Parse CLI output, don't regenerate it
**ALWAYS execute CLI first**. Never modify `.specfact/` directly. Use CLI output as grounding.

## Expected Output

## Success

```text
✓ Project bundle created: .specfact/projects/legacy-api/
✓ Analysis report: .specfact/reports/brownfield/analysis-2025-11-26T10-30-00.md
✓ Features detected: 12
✓ Stories detected: 45
```

## Error (Missing Bundle)

```text
✗ Project bundle name is required
Usage: specfact import from-code <bundle-name> [options]
```
**Success**: Bundle location, report path, summary (features/stories/contracts/relationships)
**Error**: Missing bundle name or bundle already exists

## Common Patterns

```bash
# Basic import
/specfact.01-import --repo . # Uses active plan
/specfact.01-import --bundle legacy-api --repo .

# Import with confidence threshold
/specfact.01-import --bundle legacy-api --repo . --confidence 0.7

# Import with enrichment report
/specfact.01-import --bundle legacy-api --repo . --enrichment enrichment-report.md

# Partial analysis (subdirectory only)
/specfact.01-import --bundle auth-module --repo . --entry-point src/auth/

# Spec-Kit compliance mode
/specfact.01-import --bundle legacy-api --repo . --enrich-for-speckit
/specfact.01-import --repo . --entry-point src/auth/
/specfact.01-import --repo . --enrichment report.md
```

## Context
Expand Down
72 changes: 19 additions & 53 deletions .cursor/commands/specfact.02-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,17 @@ You **MUST** consider the user input before proceeding (if not empty).

## Purpose

Manage project bundles: initialize new bundles, add features and stories, and update plan metadata. This unified command replaces multiple granular commands for better LLM workflow integration.
Manage project bundles: initialize, add features/stories, update metadata (idea/features/stories).

**When to use:**
**When to use:** Creating bundles, adding features/stories, updating metadata.

- Creating a new project bundle (greenfield)
- Adding features/stories to existing bundles
- Updating plan metadata (idea, features, stories)

**Quick Example:**

```bash
/specfact.02-plan init legacy-api
/specfact.02-plan add-feature --bundle legacy-api --key FEATURE-001 --title "User Auth"
```
**Quick:** `/specfact.02-plan init legacy-api` or `/specfact.02-plan add-feature --key FEATURE-001 --title "User Auth"`

## Parameters

### Target/Input

- `--bundle NAME` - Project bundle name (required for most operations)
- `--bundle NAME` - Project bundle name (optional, defaults to active plan set via `plan select`)
- `--key KEY` - Feature/story key (e.g., FEATURE-001, STORY-001)
- `--feature KEY` - Parent feature key (for story operations)

Expand All @@ -56,28 +47,18 @@ Manage project bundles: initialize new bundles, add features and stories, and up
### Step 1: Parse Arguments

- Determine operation: `init`, `add-feature`, `add-story`, `update-idea`, `update-feature`, `update-story`
- Extract required parameters (bundle name, keys, etc.)
- Extract parameters (bundle name defaults to active plan if not specified, keys, etc.)

### Step 2: Execute CLI

```bash
# Initialize bundle
specfact plan init <bundle-name> [--interactive/--no-interactive] [--scaffold/--no-scaffold]

# Add feature
specfact plan add-feature --bundle <name> --key <key> --title <title> [--outcomes <outcomes>] [--acceptance <acceptance>]

# Add story
specfact plan add-story --bundle <name> --feature <feature-key> --key <story-key> --title <title> [--acceptance <acceptance>]

# Update idea
specfact plan update-idea --bundle <name> [--title <title>] [--narrative <narrative>] [--target-users <users>] [--value-hypothesis <hypothesis>] [--constraints <constraints>]

# Update feature
specfact plan update-feature --bundle <name> --key <key> [--title <title>] [--outcomes <outcomes>] [--acceptance <acceptance>] [--constraints <constraints>] [--confidence <score>] [--draft/--no-draft]

# Update story
specfact plan update-story --bundle <name> --feature <feature-key> --key <story-key> [--title <title>] [--acceptance <acceptance>] [--story-points <points>] [--value-points <points>] [--confidence <score>] [--draft/--no-draft]
specfact plan add-feature [--bundle <name>] --key <key> --title <title> [--outcomes <outcomes>] [--acceptance <acceptance>]
specfact plan add-story [--bundle <name>] --feature <feature-key> --key <story-key> --title <title> [--acceptance <acceptance>]
specfact plan update-idea [--bundle <name>] [--title <title>] [--narrative <narrative>] [--target-users <users>] [--value-hypothesis <hypothesis>] [--constraints <constraints>]
specfact plan update-feature [--bundle <name>] --key <key> [--title <title>] [--outcomes <outcomes>] [--acceptance <acceptance>] [--constraints <constraints>] [--confidence <score>] [--draft/--no-draft]
specfact plan update-story [--bundle <name>] --feature <feature-key> --key <story-key> [--title <title>] [--acceptance <acceptance>] [--story-points <points>] [--value-points <points>] [--confidence <score>] [--draft/--no-draft]
# --bundle defaults to active plan if not specified
```

### Step 3: Present Results
Expand All @@ -90,13 +71,7 @@ specfact plan update-story --bundle <name> --feature <feature-key> --key <story-

**CRITICAL**: Always use SpecFact CLI commands. See [CLI Enforcement Rules](./shared/cli-enforcement.md) for details.

**Rules:**

1. **ALWAYS execute CLI first**: Run appropriate `specfact plan` command before any analysis
2. **ALWAYS use non-interactive mode for CI/CD**: Use `--no-interactive` flag in Copilot environments
3. **NEVER modify .specfact folder directly**: All operations must go through CLI
4. **NEVER create YAML/JSON directly**: All artifacts must be CLI-generated
5. **Use CLI output as grounding**: Parse CLI output, don't regenerate it
**Rules:** Execute CLI first, use `--no-interactive` in CI/CD, never modify `.specfact/` directly, use CLI output as grounding.

## Expected Output

Expand All @@ -118,28 +93,19 @@ Outcomes: Secure login, Session management
## Error (Missing Bundle)

```text
✗ Project bundle name is required
Usage: specfact plan <operation> --bundle <name> [options]
✗ Project bundle name is required (or set active plan with 'plan select')
Usage: specfact plan <operation> [--bundle <name>] [options]
```

## Common Patterns

```bash
# Initialize new bundle
/specfact.02-plan init legacy-api
/specfact.02-plan init auth-module --no-interactive

# Add feature with full metadata
/specfact.02-plan add-feature --bundle legacy-api --key FEATURE-001 --title "User Auth" --outcomes "Secure login, Session management" --acceptance "Users can log in, Sessions persist"

# Add story to feature
/specfact.02-plan add-story --bundle legacy-api --feature FEATURE-001 --key STORY-001 --title "Login API" --acceptance "API returns JWT token" --story-points 5

# Update feature metadata
/specfact.02-plan update-feature --bundle legacy-api --key FEATURE-001 --title "Updated Title" --confidence 0.9

# Update idea section
/specfact.02-plan update-idea --bundle legacy-api --target-users "Developers, DevOps" --value-hypothesis "Reduce technical debt"
/specfact.02-plan add-feature --key FEATURE-001 --title "User Auth" --outcomes "Secure login" --acceptance "Users can log in"
/specfact.02-plan add-story --feature FEATURE-001 --key STORY-001 --title "Login API" --acceptance "API returns JWT"
/specfact.02-plan update-feature --key FEATURE-001 --title "Updated Title" --confidence 0.9
/specfact.02-plan update-idea --target-users "Developers, DevOps" --value-hypothesis "Reduce technical debt"
# --bundle defaults to active plan if not specified
```

## Context
Expand Down
Loading
Loading