Skip to content

Commit 95edf16

Browse files
committed
update skills
1 parent bbdc61e commit 95edf16

4 files changed

Lines changed: 40 additions & 71 deletions

File tree

.claude/skills/add-rule/SKILL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,12 @@ Checklist: notation self-contained, complexity cited, overhead consistent, examp
172172
```bash
173173
cargo run --example export_graph # Generate reduction_graph.json for docs/paper builds
174174
cargo run --example export_schemas # Generate problem schemas for docs/paper builds
175+
make regenerate-fixtures # Regenerate example_db/fixtures/examples.json (slow, needs ILP)
175176
make test clippy # Must pass
176177
```
177178

179+
`make regenerate-fixtures` is required so the paper can load the new rule's example data from `src/example_db/fixtures/examples.json`. Without it, the `reduction-rule` entry in Step 5 will reference missing fixture data.
180+
178181
Structural and quality review is handled by the `review-pipeline` stage, not here. The run stage just needs to produce working code.
179182

180183
## Solver Rules

.claude/skills/review-pipeline/SKILL.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,33 +74,19 @@ For explicit `PR` runs, STOP after reporting.
7474

7575
If no candidate is both open and ready for review, STOP with `No Review pool PRs are currently ready for review-pipeline processing.`
7676

77-
### 0b. Create Worktree and Generate Reports
77+
### 0b. Generate Review-Pipeline Report, Create Worktree, Generate Implementation Report
7878

79-
Only after Step 0a has identified a review-ready PR should you create a worktree and spend the expensive context packets.
79+
Only after Step 0a has identified a review-ready PR should you spend the expensive context packets.
8080

81-
**Create worktree and check out the PR branch:**
81+
**Generate review-pipeline context** (from the repo root, before entering the worktree — this queries GitHub APIs only):
8282

8383
```bash
8484
REPO_ROOT=$(pwd)
85-
WORKTREE_JSON=$(python3 scripts/pipeline_worktree.py enter --name "review-pr-$PR" --format json)
86-
WORKTREE_DIR=$(printf '%s\n' "$WORKTREE_JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['worktree_dir'])")
87-
cd "$WORKTREE_DIR"
88-
gh pr checkout "$PR"
89-
```
90-
91-
**Generate both reports** (inside the worktree):
9285

93-
The two expensive context calls are allowed exactly once each per top-level `review-pipeline` invocation:
94-
95-
```bash
9686
# 1. Review-pipeline context (selection, comments, CI, linked issue)
9787
set -- python3 scripts/pipeline_skill_context.py review-pipeline --repo "$REPO" --pr "$PR" --format text
9888
REPORT=$("$@")
9989
printf '%s\n' "$REPORT"
100-
101-
# 2. Review-implementation context (scope, checklists, diff, issue compliance)
102-
IMPL_REPORT=$(python3 scripts/pipeline_skill_context.py review-implementation --repo-root . --format text)
103-
printf '%s\n' "$IMPL_REPORT"
10490
```
10591

10692
The review-pipeline report should already include:
@@ -111,14 +97,30 @@ The review-pipeline report should already include:
11197
- PR head branch
11298
- Linked Issue Context
11399

100+
**Create worktree and check out the PR branch:**
101+
102+
```bash
103+
WORKTREE_JSON=$(python3 scripts/pipeline_worktree.py enter --name "review-pr-$PR" --format json)
104+
WORKTREE_DIR=$(printf '%s\n' "$WORKTREE_JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['worktree_dir'])")
105+
cd "$WORKTREE_DIR"
106+
gh pr checkout "$PR"
107+
```
108+
109+
**Generate review-implementation context** (inside the worktree — needs git diff against main):
110+
111+
```bash
112+
# 2. Review-implementation context (scope, checklists, diff)
113+
IMPL_REPORT=$(python3 scripts/pipeline_skill_context.py review-implementation --repo-root . --format text)
114+
printf '%s\n' "$IMPL_REPORT"
115+
```
116+
114117
The review-implementation report should already include:
115118
- Review Range: base SHA, head SHA
116119
- Scope: review type (model/rule/generic), subject metadata
117120
- Deterministic Checks: whitelist + completeness status
118121
- Changed Files and Diff Stat
119-
- Linked Issue Context
120122

121-
Both reports are reused for the rest of the skill — do not regenerate either.
123+
The two expensive context calls are allowed exactly once each per top-level `review-pipeline` invocation. Both reports are reused for the rest of the skill — do not regenerate either.
122124

123125
Branch from the review-pipeline report:
124126
- `Bundle status: empty` => the selected PR is no longer eligible; run `cd "$REPO_ROOT" && python3 scripts/pipeline_worktree.py cleanup --worktree "$WORKTREE_DIR"`, then for untargeted runs return to Step 0a, for explicit `PR` runs STOP

scripts/pipeline_skill_context.py

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010
from pathlib import Path
1111
from typing import Callable
1212

13-
import pipeline_board
14-
import pipeline_checks
15-
import pipeline_pr
16-
import pipeline_worktree
13+
# Ensure sibling modules are importable regardless of how this file is invoked
14+
# (as a script, as ``python3 scripts/pipeline_skill_context.py``, or via
15+
# ``from scripts.pipeline_skill_context import ...``).
16+
sys.path.insert(0, str(Path(__file__).resolve().parent))
17+
18+
import pipeline_board # noqa: E402
19+
import pipeline_checks # noqa: E402
20+
import pipeline_pr # noqa: E402
21+
import pipeline_worktree # noqa: E402
1722

1823

1924
PROJECT_BOARD_NUMBER = 8
@@ -426,8 +431,6 @@ def render_review_implementation_text(result: dict) -> str:
426431
review_context = result.get("review_context") or {}
427432
scope = review_context.get("scope") or {}
428433
subject = review_context.get("subject") or {}
429-
current_pr = result.get("current_pr") or {}
430-
431434
lines = [
432435
"# Review Implementation Packet",
433436
"",
@@ -486,24 +489,6 @@ def render_review_implementation_text(result: dict) -> str:
486489
if diff_stat:
487490
lines.extend(["", "## Diff Stat", "```text", diff_stat, "```"])
488491

489-
lines.extend(["", "## Current PR"])
490-
if current_pr:
491-
lines.append(f"- Repo: {current_pr.get('repo')}")
492-
if current_pr.get("pr_number") is not None:
493-
lines.append(f"- PR: #{current_pr['pr_number']}")
494-
if current_pr.get("title"):
495-
lines.append(f"- Title: {current_pr['title']}")
496-
if current_pr.get("url"):
497-
lines.append(f"- URL: {current_pr['url']}")
498-
if current_pr.get("linked_issue_number") is not None:
499-
lines.append(f"- Linked issue: #{current_pr['linked_issue_number']}")
500-
else:
501-
lines.append("- No current PR detected for this branch.")
502-
503-
issue_context_text = current_pr.get("issue_context_text")
504-
if issue_context_text:
505-
lines.extend(["", "## Linked Issue Context", issue_context_text])
506-
507492
return "\n".join(lines) + "\n"
508493

509494

@@ -813,26 +798,6 @@ def default_review_implementation_context_builder(
813798
)
814799

815800

816-
def fetch_current_review_implementation_pr() -> dict | None:
817-
try:
818-
repo = pipeline_pr.fetch_current_repo()
819-
current = pipeline_pr.fetch_current_pr_data_for_repo(repo)
820-
pr_number = current.get("number")
821-
if pr_number is None:
822-
return None
823-
pr_context = pipeline_pr.build_pr_context(repo, int(pr_number))
824-
return {
825-
"repo": repo,
826-
"pr_number": int(pr_number),
827-
"title": pr_context.get("title"),
828-
"url": pr_context.get("url"),
829-
"head_ref_name": pr_context.get("head_ref_name"),
830-
"linked_issue_number": pr_context.get("linked_issue_number"),
831-
"issue_context_text": pr_context.get("issue_context_text"),
832-
}
833-
except Exception:
834-
return None
835-
836801

837802
def build_review_implementation_context(
838803
*,
@@ -846,7 +811,6 @@ def build_review_implementation_context(
846811
diff_stat_getter: Callable[[Path, str, str], str] | None = None,
847812
changed_files_getter: Callable[[Path, str, str], list[str]] | None = None,
848813
added_files_getter: Callable[[Path, str, str], list[str]] | None = None,
849-
current_pr_fetcher: Callable[[], dict | None] | None = None,
850814
review_context_builder: Callable[..., dict] | None = None,
851815
) -> dict:
852816
merge_base_getter = merge_base_getter or (
@@ -880,15 +844,13 @@ def build_review_implementation_context(
880844
f"{base_sha}..{head_sha}",
881845
)
882846
)
883-
current_pr_fetcher = current_pr_fetcher or fetch_current_review_implementation_pr
884847
review_context_builder = review_context_builder or default_review_implementation_context_builder
885848

886849
base_sha = merge_base_getter(repo_root)
887850
head_sha = head_sha_getter(repo_root)
888851
diff_stat = diff_stat_getter(repo_root, base_sha, head_sha)
889852
changed_files = changed_files_getter(repo_root, base_sha, head_sha)
890853
added_files = added_files_getter(repo_root, base_sha, head_sha)
891-
current_pr = current_pr_fetcher()
892854
review_context = review_context_builder(
893855
repo_root,
894856
diff_stat=diff_stat,
@@ -909,7 +871,6 @@ def build_review_implementation_context(
909871
"head_sha": head_sha,
910872
},
911873
"review_context": review_context,
912-
"current_pr": current_pr,
913874
}
914875

915876

scripts/pipeline_worktree.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,13 @@ def cleanup_worktree(*, worktree: str | Path) -> dict:
343343
worktree = Path(worktree).resolve()
344344
# Determine repo root before cleanup — if the worktree is already gone,
345345
# fall back to the parent .worktrees directory's repo.
346-
try:
347-
repo_root = repo_root_from(worktree)
348-
except Exception:
349-
# Worktree dir may already be deleted; derive repo root from parent.
346+
if worktree.is_dir():
347+
try:
348+
repo_root = repo_root_from(worktree)
349+
except Exception:
350+
repo_root = worktree.parent.parent
351+
else:
352+
# Worktree dir already deleted; derive repo root from parent.
350353
repo_root = worktree.parent.parent # .worktrees/<branch> -> repo root
351354
repo_root = Path(repo_root).resolve()
352355

0 commit comments

Comments
 (0)