Agent skill
distilling-prs
Use when reviewing PRs to triage, categorize, or summarize changes requiring human attention. Triggers: 'summarize this PR', 'what changed in PR #X', 'triage PR', 'which files need review', 'PR overview', 'categorize changes', or pasting a PR URL. NOT for: deep code analysis (use advanced-code-review) or quick review (use code-review).
Install this agent skill to your Project
npx add-skill https://github.com/axiomantic/spellbook/tree/main/skills/distilling-prs
SKILL.md
PR Distill Skill
<ROLE>PR Review Analyst. Your reputation depends on accurately identifying which changes need human review and which are safe to skip.</ROLE>
Invariant Principles
- Heuristics First, AI Second: Always run heuristic pattern matching before invoking AI analysis. Heuristics are fast and deterministic.
- Confidence Requires Evidence: Never mark a change as "safe to skip" without a pattern match or AI explanation justifying the confidence level.
- Surface Uncertainty: When confidence is low, categorize as "uncertain" rather than guessing. Humans decide ambiguous cases.
- Preserve Context: Report must include enough diff context for reviewers to understand changes without switching to the PR itself.
MCP Tools
| Tool | Purpose |
|---|---|
pr_fetch |
Fetch PR metadata and diff from GitHub |
pr_diff |
Parse unified diff into FileDiff objects |
pr_files |
Extract file list from pr_fetch result |
pr_match_patterns |
Match heuristic patterns against file diffs |
pr_bless_pattern |
Bless a pattern for elevated precedence |
pr_list_patterns |
List all available patterns (builtin and blessed) |
Execution Flow
Three-phase model: heuristics → AI analysis → report.
Phase 1: Fetch, Parse, Match
pr_data = pr_fetch("<pr-identifier>") # Fetch PR data
diff_result = pr_diff(pr_data["diff"]) # Parse the diff
match_result = pr_match_patterns(
files=diff_result["files"],
project_root="/path/to/project"
)
Produces:
match_result["matched"]: Files with pattern matches (categorized)match_result["unmatched"]: Files requiring AI analysis
On MCP tool failure: If pr_fetch or pr_match_patterns fails, halt and surface the error to the user. Do not proceed with partial data.
Phase 2: AI Analysis (if needed)
For unmatched files, analyze each to determine:
- review_required: Significant logic, API, or behavior changes
- safe_to_skip: Formatting, comments, trivial refactors
- uncertain: When confidence is low, surface for human decision
Phase 3: Generate Report
Produce a markdown report with:
- Summary of changes by category (review_required, safe_to_skip, uncertain)
- Full diffs for review_required items
- Pattern matches with confidence levels
- Discovered patterns with bless commands
Examples
# Analyze PR by number (uses current repo context)
pr_data = pr_fetch("123")
# Analyze PR by URL
pr_data = pr_fetch("https://github.com/owner/repo/pull/123")
# Parse and match
diff_result = pr_diff(pr_data["diff"])
match_result = pr_match_patterns(
files=diff_result["files"],
project_root="/Users/alice/project"
)
# Bless a discovered pattern
pr_bless_pattern("/Users/alice/project", "query-count-json")
# List all patterns
patterns = pr_list_patterns("/Users/alice/project")
Configuration
Config file: ~/.local/spellbook/docs/<project-encoded>/distilling-prs-config.json
{
"blessed_patterns": ["query-count-json", "import-cleanup"],
"always_review_paths": ["**/migrations/**", "**/permissions.py"],
"query_count_thresholds": {
"relative_percent": 20,
"absolute_delta": 10
}
}
Builtin Patterns
15 builtin patterns across three confidence levels. Use pr_list_patterns() to see all with IDs and descriptions.
Always Review (5): migration files, permission changes, model changes, signal handlers, endpoint changes
High Confidence (5): settings changes, query count JSON, debug print statements, import cleanup, gitignore updates
Medium Confidence (5): backfill commands, decorator removals, factory setup, test renames, test assertion updates
<FINAL_EMPHASIS> Heuristics before AI, always. A mis-categorized "safe to skip" sends a reviewer past a breaking change. Surface uncertainty rather than hide it. </FINAL_EMPHASIS>
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
spellbook-auditing
Meta-audit skill for spellbook development. Spawns parallel subagents to factcheck docs, optimize instructions, find token savings, and identify MCP candidates. Produces actionable report.
documentation-updates
Use after modifying library skills, library commands, or agents to ensure CHANGELOG, README, and docs are updated
project-encyclopedia
[DEPRECATED] Use project-level AGENTS.md files instead. Previously used for first-session codebase onboarding and persistent glossary creation.
reviewing-impl-plans
Use when reviewing implementation plans before execution. Triggers: 'is this plan solid', 'review the plan', 'check before I start building', 'anything missing from this plan', 'will this plan work', 'audit the implementation plan'. NOT for: reviewing design documents (use reviewing-design-docs) or creating plans (use writing-plans).
session-resume
Session resume protocol and session repairs handling. Loaded when spellbook_session_init returns resume_available: true, or when session_init returns a repairs array. Triggers: 'resume', 'continue', 'where were we', session resume, session repairs.
brainstorming
Use when exploring design approaches, generating ideas, or making architectural decisions. Triggers: 'explore options', 'what are the tradeoffs', 'how should I approach', 'let's think through', 'sketch out an approach', 'I need ideas for', 'how would you structure', 'what are my options'. Also invoked by develop when design decisions are needed.
Didn't find tool you were looking for?