Chapter 7

CLI Reference

Every command, every flag, every example. The chapter you bookmark.

Overview

The pforge CLI is a convenience wrapper — two scripts, no dependencies beyond Git and your shell. Every command shows the equivalent manual steps, so non-CLI users can follow along.

PlatformFileUsage
Windows / PowerShellpforge.ps1.\pforge.ps1 <command>
macOS / Linux / Bashpforge.sh./pforge.sh <command>
Not there? Both scripts are copied to your project root during setup.ps1 / setup.sh. If they're missing, copy them manually from the Plan Forge repo.
analyze vs diagnose — which do I use?
pforge analyze scores a plan's quality (traceability, coverage, gates — 0 to 100).
pforge diagnose investigates a bug in code (root cause, fix recommendations).
One tells you if your blueprint is solid. The other finds out why the bridge collapsed.
Use analyze after hardening a plan. Use diagnose when a slice fails.

Commands

pforge init
Bootstrap a project with the Plan Forge Pipeline. Delegates to setup.ps1 / setup.sh.
FlagTypeDescription
-PresetstringTech preset: dotnet, typescript, python, java, go, swift, rust, php, azure-iac. Comma-separated for multi-preset.
-ProjectPathpathTarget project directory (default: current dir)
-AgentstringAgent adapter: copilot, claude, cursor, codex, gemini, windsurf, generic, all
Bootstrap a project
.\pforge.ps1 init -Preset dotnet
.\pforge.ps1 init -Preset typescript -ProjectPath ./my-app
.\pforge.ps1 init -Preset dotnet -Agent all
Bash equivalent
./pforge.sh init --preset dotnet
./pforge.sh init --preset typescript --path ./my-app
./pforge.sh init --preset dotnet --agent all
Equivalent manual steps
  1. Run .\setup.ps1 / ./setup.sh with your preferred parameters
  2. Follow the interactive wizard
pforge check
Validate that setup completed correctly. Delegates to validate-setup.ps1 / validate-setup.sh.
PowerShell / Bash
pforge check
Equivalent manual steps
  1. Run .\validate-setup.ps1
  2. Review the output for any missing files
pforge status
Show all phases from DEPLOYMENT-ROADMAP.md with their current status.
PowerShell / Bash
pforge status
Example output
Phase Status (from DEPLOYMENT-ROADMAP.md):
─────────────────────────────────────────────
  Phase 1: User Authentication  📋 Planned
  Phase 2: Dashboard Widgets    🚧 In Progress
pforge new-phase <name>
Create a new phase plan file and add an entry to the deployment roadmap.
Arg / FlagTypeDescription
namestring (required)Phase name, e.g. user-auth
--dry-runbooleanPreview without creating
PowerShell
.\pforge.ps1 new-phase user-auth --dry-run
.\pforge.ps1 new-phase user-auth
What it does
  1. Finds the next phase number (e.g., Phase 3)
  2. Creates docs/plans/Phase-3-USER-AUTH-PLAN.md from template
  3. Adds a Phase 3 entry to DEPLOYMENT-ROADMAP.md
pforge branch <plan-file>
Create a Git branch matching the plan's declared Branch Strategy.
Arg / FlagTypeDescription
planpath (required)Path to plan file
--dry-runbooleanPreview without creating
PowerShell
.\pforge.ps1 branch docs/plans/Phase-3-USER-AUTH-PLAN.md --dry-run
.\pforge.ps1 branch docs/plans/Phase-3-USER-AUTH-PLAN.md
CLI-only — not available as MCP tool. Use via terminal.
pforge commit <plan-file> <slice-number>
Stage all changes and commit with a conventional commit message derived from the slice's goal.
Arg / FlagTypeDescription
planpath (required)Path to plan file
slicenumber (required)Slice number
--dry-runbooleanPreview commit message without committing
PowerShell
.\pforge.ps1 commit docs/plans/Phase-3.md 2 --dry-run
.\pforge.ps1 commit docs/plans/Phase-3.md 2
CLI-only — not available as MCP tool.
pforge phase-status <plan-file> <status>
Update a phase's status in the deployment roadmap.
ArgTypeDescription
planpath (required)Path to plan file
statusenum (required)planned · in-progress · complete · paused
PowerShell
.\pforge.ps1 phase-status docs/plans/Phase-3.md in-progress
.\pforge.ps1 phase-status docs/plans/Phase-3.md complete
CLI-only — not available as MCP tool.
pforge sweep
Scan all code files for deferred-work markers: TODO, FIXME, HACK, stub, placeholder, mock data.
PowerShell / Bash
pforge sweep
Example output
Completeness Sweep — scanning for deferred-work markers:
─────────────────────────────────────────────────────────
  src/Services/UserService.cs:42: // TODO: Wire to real email service
  src/Controllers/AuthController.cs:18: // FIXME: Add rate limiting

FOUND 2 deferred-work marker(s). Resolve before Step 5 (Review Gate).

Also available as: forge_sweep MCP tool

pforge diff <plan-file>
Compare changed files against the plan's Scope Contract. Flags forbidden files, unplanned files, and confirms in-scope changes.
PowerShell
.\pforge.ps1 diff docs/plans/Phase-3-USER-AUTH-PLAN.md
Example output
Scope Drift Check — 4 changed file(s) vs plan:
──────────────────────────────────────────────────
  ✅ IN SCOPE   src/Services/UserService.cs
  ✅ IN SCOPE   src/Repositories/UserRepository.cs
  🟡 UNPLANNED  src/Config/AppSettings.cs
  🔴 FORBIDDEN  tests/Legacy/OldTests.cs

DRIFT DETECTED — 1 forbidden file(s) touched.

Also available as: forge_diff MCP tool

pforge analyze <plan-file>
Cross-artifact consistency scoring — validates traceability, scope coverage, test coverage, and gate definitions. Scores 0–100.
FlagTypeDescription
--quorumbooleanMulti-model consensus analysis
--modeplan | fileExplicit analysis mode (auto-detected if omitted)
--modelsstringComma-separated model override
Analyze plan consistency
# Single-model analysis
.\pforge.ps1 analyze docs/plans/Phase-1-AUTH-PLAN.md

# Multi-model quorum
.\pforge.ps1 analyze docs/plans/Phase-1-AUTH-PLAN.md --quorum

# Analyze a code file directly
.\pforge.ps1 analyze src/services/billing.ts --mode file

Scoring Dimensions

DimensionPointsWhat It Checks
Traceability25MUST/SHOULD criteria exist, slices defined, criteria mapped to slices
Coverage25Changed files within Scope Contract, no forbidden edits
Test Coverage25MUST criteria matched against test files via keyword fuzzy matching
Gates25Validation gates referenced in slices, no deferred-work markers

Exit codes: 0 = pass (≥60), 1 = fail (<60). Also available as: forge_analyze MCP tool.

pforge diagnose <file>
Multi-model bug investigation — dispatches file analysis to multiple AI models independently, then synthesizes root cause analysis with fix recommendations.
FlagTypeDescription
--modelsstringComma-separated model override
Investigate a bug
.\pforge.ps1 diagnose src/services/billing.ts
.\pforge.ps1 diagnose src/auth/token-validator.ts --models grok-3-mini,grok-4

Each model analyzes independently for: root cause, failure modes, reproduction steps, impact assessment, fix recommendations, regression risk.

Output saved to: .forge/analysis/diagnose-*. Also available as: forge_diagnose MCP tool.

pforge run-plan <plan-file>
Execute a hardened plan — spawn CLI workers for each slice, validate at every boundary, track tokens and cost.
FlagTypeDefaultDescription
--estimatebooleanCost prediction only, no execution
--assistedbooleanHuman codes, orchestrator validates gates
--modelstringModel override (e.g., claude-sonnet-4.6)
--resume-fromnumberSkip completed slices, resume from N
--dry-runbooleanParse and validate without executing
--quorumboolean | autoForce quorum on all slices, or auto for threshold-based
--quorum-thresholdnumber6Complexity threshold for auto quorum (1–10)
Execute a plan (5 modes)
# Estimate cost without executing
.\pforge.ps1 run-plan docs/plans/Phase-7.md --estimate

# Full auto execution
.\pforge.ps1 run-plan docs/plans/Phase-7.md

# Assisted mode
.\pforge.ps1 run-plan docs/plans/Phase-7.md --assisted

# Resume from slice 3 after fixing a failure
.\pforge.ps1 run-plan docs/plans/Phase-7.md --resume-from 3

# Quorum mode with custom threshold
.\pforge.ps1 run-plan docs/plans/Phase-7.md --quorum=auto --quorum-threshold 8

Execution Modes

ModeFlagWhat Happens
Full Auto(default)gh copilot CLI executes each slice with full project context
Assisted--assistedYou code in VS Code; orchestrator prompts and validates gates
Estimate--estimateShows slice count, token estimate, and cost — without executing

Results written to: .forge/runs/<timestamp>/. Also available as: forge_run_plan MCP tool.

pforge smith
Inspect your forge — diagnose environment, VS Code config, setup health, version currency, and common problems. Every issue includes a FIX: suggestion.
PowerShell / Bash
pforge smith

What The Smith Checks

CategoryChecks
Environmentgit, VS Code CLI, PowerShell/bash version, GitHub CLI
VS Code Configchat.agent.enabled, chat.useCustomizationsInParentRepositories, chat.promptFiles
Setup Health.forge.json valid, copilot-instructions.md exists, file counts match preset
Version CurrencyInstalled templateVersion vs source VERSION
Common ProblemsDuplicate instructions, orphaned agents, missing applyTo, unresolved placeholders

Also available as: forge_smith MCP tool.

pforge ext <subcommand>
Extension management — browse, install, remove, and publish guardrail extensions.
SubcommandDescription
ext search [query]Browse the community catalog. Omit query for all extensions.
ext add <name>Download and install from catalog in one step.
ext info <name>Show detailed info before installing.
ext install <path>Install from a local directory path.
ext listList all installed extensions.
ext remove <name>Remove an installed extension.
ext publish <path>Generate a catalog entry for submission via PR.
Manage extensions
.\pforge.ps1 ext search saas
.\pforge.ps1 ext add saas-multi-tenancy
.\pforge.ps1 ext info plan-forge-memory
.\pforge.ps1 ext list
.\pforge.ps1 ext remove healthcare-compliance
.\pforge.ps1 ext publish .forge/extensions/my-extension

Also available as: forge_ext_search, forge_ext_info MCP tools.

pforge update [source-path]
Update framework files from a Plan Forge source without re-running the full setup wizard. Preserves all user-customized files.
FlagTypeDescription
sourcepath (optional)Plan Forge source path (auto-detects ../plan-forge)
--dry-runbooleanPreview changes without applying
--forcebooleanSkip confirmation prompt
Update framework files
.\pforge.ps1 update
.\pforge.ps1 update C:\path\to\plan-forge --dry-run
.\pforge.ps1 update --force

What Gets Updated vs Protected

Updated (safe to replace)Never Touched (your files)
Pipeline prompts, agents, shared instructions, runbook, lifecycle hooks, new preset files copilot-instructions.md, project-profile, project-principles, DEPLOYMENT-ROADMAP.md, .forge.json, plan files, existing preset files
Bootstrapping from older versions: If your pforge.ps1 doesn't have the update command yet (pre-v1.2.1), download the latest script first, then run pforge update.
pforge help
Show help — list all available commands with one-line descriptions.
PowerShell / Bash
pforge help

MCP Server Commands

The MCP server is started directly with Node.js, not through the pforge CLI:

node pforge-mcp/server.mjs
Start the full stack: MCP (stdio) + Express (HTTP on 3100) + WebSocket (3101). Use with .vscode/mcp.json for auto-start.
Terminal
# Full MCP server (normal usage — started by VS Code via mcp.json)
node pforge-mcp/server.mjs

# Dashboard + REST API only (no MCP stdio)
node pforge-mcp/server.mjs --dashboard-only

# Custom project path
node pforge-mcp/server.mjs --project /path/to/project

Full Reference

This chapter covers the happy path for each command. For exhaustive edge-case documentation, see the full source: CLI-GUIDE.md