Feature Breakdown & Architecture
A complete inventory of what pr-to-spec does, how it's built, and what risks it classifies.
Features
PR Analysis
coreAnalyze any GitHub PR into a structured spec with risk classification
Local Scan
coreAnalyze local branches, staged changes, or last N commits
Intent Declaration
coreDeclare expected scope, risk ceiling, and change type
Drift Detection
coreDetect scope creep, forbidden touches, risk escalation
MCP Server
new6-tool Model Context Protocol server for IDE integration
Verification Contracts
v0.7Declarative rules: no_new_dependencies, max_files_changed, etc.
Intent DAG
v0.7Graph-based intent tracking with decision taxonomy
Agent Protocol
coreJSON envelope with version, status, exit codes, signals
Risk Classification
core10 categories from authentication to large-change
AI Enhancement
optOptional Anthropic/OpenAI summaries with --ai-enhance
GitHub Action
coreAutomated PR spec generation in CI/CD pipelines
Architecture
src/
servers/ MCP server (6 tools via stdio transport)
cli/ CLI entrypoints (analyze, scan, intent, check)
action/ GitHub Action entrypoint
core/
schema/ Zod schema for the canonical prompt-spec format
github/ Octokit-based PR data fetching
sources/ DiffSource abstraction (GitHub PR, local branch, staged, commits)
parsing/ Deterministic spec generation from diff metadata
risk/ Rule-based risk classification heuristics
intent/ Intent schema and YAML storage (.pr-to-spec/intent.yaml)
drift/ Drift detection against declared intent
protocol/ Agent protocol envelope (version, status, exit_code)
rendering/ YAML, Markdown, JSON, and PR comment renderers
ai/ Optional AI enhancement (Anthropic, OpenAI)
diff/ Spec version diffing Design Principles
Before & After
Before pr-to-spec
- Agent reads raw diffs — no structure, no risk signals
- No intent declaration — scope creep undetected
- Manual PR review copy-paste to LLM context
- No exit codes — agents can't gate on risk
- No audit trail — "what did the agent see?"
After pr-to-spec
- Structured JSON envelope — version, status, signals
- Intent + drift detection catches scope creep early
- One command: pr-to-spec check --json | agent review
- Clean exit codes: 0 clean, 2 high-risk, 3 drift, 4 gate fail
- Full spec artifact — reproducible, auditable, deterministic
Risk Classification
authentication
highAuth, login, session, OAuth, JWT files
secrets
high.env, .key, .pem, credentials files
database
highMigrations, .sql, schema files
permissions
highRBAC, ACL, policy files
payment
highStripe, billing, subscription files
dependencies
mediumLockfiles, package managers
infrastructure
mediumDocker, Terraform, k8s, deploy configs
destructive-operations
mediumDROP TABLE, DELETE FROM in patches
security-config
mediumCORS, CSP, security headers
large-change
low300+ line changes in a single file
Security Posture
No Execution
Never runs code — metadata and diffs only
Read-Only Default
Only reads PRs and diffs, writes nothing unless --comment
Zod-Validated Output
All spec output is schema-validated before rendering
SSRF Prevention
Webhook URLs validated: HTTPS required, private IPs blocked
No Command Injection
custom_command contract type removed, always fails
Prototype Pollution Guard
--field extraction blocks __proto__ traversal