Skip to main content
AI/MLjeremylongshore

pr-to-spec

Analyze code changes and detect intent drift using pr-to-spec CLI

Stars
2,267
Source
jeremylongshore/claude-code-plugins-plus-skills
Updated
2026-05-31
Slug
jeremylongshore--claude-code-plugins-plus-skills--pr-to-spec
View on GitHubRaw SKILL.md

// install — copy + paste into any project

mkdir -p .claude/skills && curl -fsSL https://raw.githubusercontent.com/jeremylongshore/claude-code-plugins-plus-skills/HEAD/plugins/mcp/pr-to-spec/.claude/skills/pr-to-spec/SKILL.md -o .claude/skills/pr-to-spec.md

Drops the SKILL.md into .claude/skills/pr-to-spec.md. Works with Claude Code, Cursor, and any agent that loads SKILL.md files from .claude/skills/.

pr-to-spec Skill

Convert code changes into structured, agent-consumable specs with intent drift detection.

Commands

/pr-to-spec scan

Analyze current branch changes vs main and output a structured spec.

pr-to-spec scan --branch main --json

Use --diff N to scan last N commits, or --staged for staged changes only.

/pr-to-spec check

Scan current changes AND check for drift against declared intent.

pr-to-spec check --json

Returns exit code 3 if drift is detected, 2 if high-risk, 0 if clean.

/pr-to-spec intent set

Declare what this change is supposed to do.

pr-to-spec intent set --goal "Add rate limiting to API" --scope "src/middleware/**" --forbid "src/db/**" --max-risk medium

/pr-to-spec intent show

Show the current intent declaration.

pr-to-spec intent show --json

Agent Protocol

All --json output is wrapped in the agent protocol envelope:

{
  "version": 1,
  "command": "check",
  "status": "drift_detected",
  "exit_code": 3,
  "signals": [...],
  "spec": {...},
  "intent": {...}
}

Exit Codes

Code Meaning
0 Clean — no issues
1 Error
2 High-risk changes detected
3 Drift detected

Usage in CLAUDE.md

Add to your project's CLAUDE.md:

## Change Validation

Before any significant code change:
1. Set intent: `pr-to-spec intent set --goal "..." --scope "..." --max-risk medium`
2. After changes: `pr-to-spec check --json` — exit 3 means drift, investigate before continuing