pr-review-mining
Extract Intent Layer content from GitHub PR descriptions and review comments. Mines merged PRs for pitfalls, contracts, architecture decisions, and anti-patterns that should be documented in AGENTS.md files.
What this skill does
# PR Review Mining
Extract tribal knowledge from GitHub PR discussions to populate Intent Layer nodes.
## Why PR Reviews?
PR descriptions and review comments contain valuable context that commit messages lack:
- **Breaking Changes sections** → Contracts (what invariants changed)
- **"Why" sections** → Architecture Decisions (rationale)
- **Review warnings** → Pitfalls ("don't forget to handle X")
- **Alternatives Considered** → Anti-patterns (what didn't work)
- **Requested Changes** → Contracts (patterns reviewers enforce)
This context is richer than commit messages because PRs capture the *discussion* around changes.
## Quick Start
```bash
# Find merged PRs affecting a directory
gh pr list --state merged --search "path/to/directory" --json number,title,body --limit 50
# Get review comments for a specific PR
gh api repos/{owner}/{repo}/pulls/{number}/comments
# Get review decisions (APPROVE/REQUEST_CHANGES)
gh api repos/{owner}/{repo}/pulls/{number}/reviews
```
---
## Extraction Workflow
### Step 1: Gather PRs
For the target directory, collect merged PRs:
```bash
# Get PR metadata
gh pr list --state merged --search "[directory]" --json number,title,body,mergedAt --limit 100
# For time-bounded search
gh pr list --state merged --search "[directory] merged:>2024-01-01" --json number,title,body --limit 100
```
### Step 2: Parse PR Bodies (Section-Based)
Look for structured sections in PR descriptions:
| PR Section | Intent Layer Section | Signal |
|------------|---------------------|--------|
| `## What` / `## Summary` | Entry Points | What capability was added |
| `## Why` / `## Motivation` | Architecture Decisions | Rationale for change |
| `## Breaking Changes` | Contracts | Invariants that changed |
| `## How to Test` | Entry Points | Verification patterns |
| `## Risks` / `## Concerns` | Pitfalls | Known edge cases |
| `## Alternatives Considered` | Architecture Decisions / Anti-patterns | Why not other approaches |
### Step 3: Extract Review Comments
For each PR, fetch review comments:
```bash
# Top-level review comments
gh api repos/{owner}/{repo}/pulls/{number}/comments --jq '.[].body'
# Review decisions with comments
gh api repos/{owner}/{repo}/pulls/{number}/reviews --jq '.[] | select(.body != "") | .body'
```
Apply keyword fallback to unstructured content.
### Step 4: Keyword Fallback
For comments and unstructured PR bodies:
| Pattern | Target Section | Examples |
|---------|----------------|----------|
| `don't`, `never`, `avoid`, `careful` | Pitfalls | "don't forget to handle null" |
| `instead of`, `rather than`, `we decided` | Architecture Decisions | "we use Redis instead of memcached" |
| `must`, `always`, `required`, `invariant` | Contracts | "auth must happen before DB write" |
| `broke`, `regression`, `caused`, `issue` | Pitfalls | "this caused issues in prod" |
| `reverted`, `rolled back`, `didn't work` | Anti-patterns | "we tried X but rolled back" |
| `breaking`, `migration`, `deprecate` | Contracts | "this is a breaking change" |
### Step 5: Score Confidence
| Confidence | Signal |
|------------|--------|
| **High** | Explicit section match (Breaking Changes, Risks) |
| **High** | REQUEST_CHANGES review with clear pattern |
| **Medium** | Strong keyword match in context |
| **Low** | Weak keyword or ambiguous context |
---
## Parallel PR Analysis
For repos with many PRs, use parallel subagents:
### Parallel by PR Batch
```
Task 1 (Explore): "Mine PRs #1-50 for [directory].
Extract: pitfalls from Risks/warnings,
contracts from Breaking Changes,
decisions from Why/Alternatives.
Return as Intent Layer findings."
Task 2 (Explore): "Mine PRs #51-100 for [directory].
Extract: pitfalls from Risks/warnings,
contracts from Breaking Changes,
decisions from Why/Alternatives.
Return as Intent Layer findings."
```
### Parallel by Category
```
Task 1 (Explore): "Search PR descriptions for [directory] for Breaking Changes.
Extract contracts and invariants.
Return with PR numbers and confidence."
Task 2 (Explore): "Search PR review comments for [directory] for warnings.
Look for 'don't', 'careful', 'must'.
Return as potential Pitfalls."
Task 3 (Explore): "Search PRs for [directory] for Alternatives Considered.
Extract architecture decisions and anti-patterns.
Return with rationale from PR."
```
---
## Output Format
After analysis, present findings for human review:
```markdown
## PR Review Mining Findings for [directory]
### Potential Pitfalls (from PR discussions)
| PR | Finding | Source | Confidence |
|----|---------|--------|------------|
| #234 | Upstream API returns 429 without Retry-After header | Review comment | High |
| #189 | Cache invalidation race when multiple pods restart | PR body (Risks) | High |
| #156 | Don't use DELETE cascade on user table | Review comment | Medium |
### Potential Architecture Decisions (from PR rationale)
| PR | Finding | Source | Confidence |
|----|---------|--------|------------|
| #201 | Chose event sourcing over CRUD for audit trail | PR body (Why) | High |
| #178 | Redis over Memcached for pub/sub support | Review thread | Medium |
### Potential Contracts (from breaking changes)
| PR | Finding | Source | Confidence |
|----|---------|--------|------------|
| #245 | All API responses must include request_id | PR body (Breaking) | High |
| #198 | Auth tokens must be validated before any DB write | REQUEST_CHANGES | High |
### Potential Anti-patterns (from rejected approaches)
| PR | Finding | Source | Confidence |
|----|---------|--------|------------|
| #212 | Don't store sessions in local memory (doesn't scale) | Alternatives Considered | High |
| #167 | Avoid synchronous calls to payment API | Review comment | Medium |
---
**Review needed**: Human should verify findings before adding to AGENTS.md.
Links: [#234](url) [#189](url) ...
```
---
## Integration with Other Skills
### With intent-layer (setup)
Use pr-review-mining during initial setup alongside git-history:
1. Run structure analysis
2. For each candidate directory:
- Run git-history analysis (commits)
- Run pr-review-mining (PR discussions)
3. Merge and deduplicate findings
4. Human reviews and refines
### With git-history (complementary)
| Source | Strength | Weakness |
|--------|----------|----------|
| git-history | Covers all changes | Terse commit messages |
| pr-review-mining | Rich "why" context | Only merged PRs with discussions |
Use both for complete coverage:
- git-history catches changes without PR discussion
- pr-review-mining provides deeper rationale
### With intent-layer-maintenance (audits)
After significant merges:
1. Run `detect_changes.sh` to find affected nodes
2. Mine recent PRs touching those areas
3. Check if new pitfalls/contracts emerged
4. Propose updates based on PR discussions
---
## Limitations
| Limitation | Mitigation |
|------------|------------|
| Squash merges lose PR context | Search by merge commit date range |
| Empty PR descriptions | Fall back to review comments |
| No PR template | Use keyword fallback |
| Private repos | Requires `gh` auth with repo access |
| Rate limits | Use `--limit` flag, batch requests |
---
## Example Session
**Goal**: Populate Pitfalls for `src/api/` directory
**Step 1**: Find relevant PRs
```bash
gh pr list --state merged --search "src/api" --json number,title --limit 20
```
Output:
```
#234 fix: handle null response from payment API
#212 refactor: move to event-driven architecture
#198 feat: add request ID to all responses
```
**Step 2**: Extract from PR #234
```bash
gh pr view 234 --json body
```
Body contains:
```markdown
## Why
The payment API sometimes returns null instead of an error object.
## Risks
- Other upstream APIs mighRelated in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.