Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
42 changes: 42 additions & 0 deletions extensions/whatif/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# What-if Analysis Extension

Preview the downstream impact of requirement changes before committing to them.

## Overview

The What-if Analysis extension provides a read-only simulation tool for spec-driven development. It allows teams to preview how a proposed change will affect:

- **Complexity**: Heuristic scoring of project difficulty.
- **Effort**: Estimated person-hours for implementation.
- **Tasks**: Delta in the task list (added, removed, changed).
- **Risks**: Potential technical debt, breaking changes, or conflicts.

## Installation

```bash
specify extension add whatif
```

Or for development:

```bash
specify extension add --dev path/to/whatif
```

## Usage

Invoke the command through your AI assistant:

```bash
/speckit.whatif.analyze "Change the database from SQLite to PostgreSQL"
```

The agent will analyze your current artifacts (`spec.md`, `plan.md`, `tasks.md`, `constitution.md`) and generate a detailed impact report without modifying any files.

## Commands

### `speckit.whatif.analyze`

Performs the simulation and generates the report.

**Arguments**: The hypothetical scenario or requirement change to analyze.
131 changes: 131 additions & 0 deletions extensions/whatif/commands/analyze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
description: Preview the downstream impact (complexity, effort, tasks, risks) of requirement changes before committing to them.
scripts:
sh: ../../scripts/bash/check-prerequisites.sh --json --include-tasks
ps: ../../scripts/powershell/check-prerequisites.ps1 -Json -IncludeTasks
---

# What-if Analysis

Use this command to preview the impact of requirement changes on complexity, effort, and task breakdown without modifying any files.

## User Input

```text
$ARGUMENTS
```

You **MUST** use this input as the "What-if Scenario" to analyze. If empty, prompt the user for a scenario.

## Goal

Provide a detailed, read-only simulation of how the proposed requirement change would impact the project's specification, implementation plan, and task breakdown. Help the team make data-driven decisions about whether to proceed with the change.

## Operating Constraints

**STRICTLY READ-ONLY**: Do **not** modify any files. This is a pure in-memory simulation.

## Execution Steps

### 1. Initialize Simulation Context

Run `{SCRIPT}` once from repo root and parse JSON for FEATURE_DIR and AVAILABLE_DOCS.
Load core artifacts from FEATURE_DIR:
- **spec.md**: Current requirements and priorities.
- **plan.md**: Current architecture and technical choices.
- **tasks.md**: Current task list and effort markers.
- **constitution**: Project principles (from `/memory/constitution.md`).

### 2. Formulate Simulated State

In your context, model the project as it would look *after* the proposed change:
- **Requirements**: Which are added, removed, or modified?
- **Architecture**: What technical changes are required (new libraries, DB schema changes, API updates)?
- **Tasks**: What is the delta in the task list?

### 3. Calculate Impact Metrics

Derive the following deltas based on your assessment:

#### A. Complexity Score (1-100)
- **Current Score**: Based on requirement count, dependency depth, and technical risk.
- **Simulated Score**: Based on the project state after the change.
- **Delta**: (Simulated - Current).

#### B. Effort Delta (Hours)
- Estimate the total person-hours required to implement the change.
- Breakdown: Research, Development, Testing, Refactoring.

#### C. Task Count Delta
- Number of tasks to be added, removed, or significantly altered.

### 4. Risk Assessment

Identify potential pitfalls:
- **Breaking Changes**: Impact on existing APIs or data.
- **Architecture Drift**: Does the change move the project away from its original goal?
- **Constitution Conflicts**: Does the change violate any project principles?
- **Integration Debt**: New dependencies or maintenance overhead.

### 5. Generate Simulation Report

Output a structured Markdown report (no file writes) with the following structure:

# "What-if" Analysis: [Scenario Summary]

## Executive Summary

| Metric | Current | Simulated | Delta |
|--------|---------|-----------|-------|
| Complexity Score | [Score] | [Score] | [+/- Delta] |
| Total Tasks | [Count] | [Count] | [+/- Delta] |
| Estimated Effort | [Hours] | [Hours] | [+/- Hours] |

**Risk Level**: [LOW | MEDIUM | HIGH | CRITICAL]

---

## 🏗️ Impacted Artifacts

### 📋 Specification (spec.md)
- **Changes**: [Briefly list requirement alterations]
- **Impact**: [High-level impact on user value]

### 📐 Implementation Plan (plan.md)
- **Changes**: [Briefly list architectural updates]
- **Impact**: [Technological implications]

### ✅ Task Breakdown (tasks.md)
- **[ADDED]**: [T-NEW-1] Description...
- **[REMOVED]**: [T-OLD-4] Description...
- **[CHANGED]**: [T-MOD-12] Description...

---

## 🚦 Risk Assessment

| Potential Risk | Severity | Mitigation Suggestion |
|----------------|----------|-----------------------|
| [Risk Title] | [Severity] | [Strategy] |

---

## 📊 Side-by-Side Preview (Simulated)

Show a diff-like preview for the most significant file change (typically spec.md or plan.md).

```markdown
<<<< CURRENT
[Original Content Snippet]
==== SIMULATED
[New Content Snippet]
>>>>
```

## 🏁 Recommendation

Provide a clear "Go / No-Go" recommendation based on the data. Suggest follow-up commands (e.g., "/speckit.specify" to apply these changes) if the user decides to proceed.

## Context

$ARGUMENTS
24 changes: 24 additions & 0 deletions extensions/whatif/extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
schema_version: "1.0"

extension:
id: whatif
name: "What-if Analysis"
version: "1.0.0"
description: "Preview the downstream impact (complexity, effort, tasks, risks) of requirement changes before committing to them."
author: "DevAbdullah90"
repository: "https://github.com/github/spec-kit"
license: "MIT"

requires:
speckit_version: ">=0.6.0"

provides:
commands:
- name: speckit.whatif.analyze
file: commands/analyze.md
description: "Analyze the impact of requirement changes"

tags:
- "analysis"
- "planning"
- "simulation"