Skip to content

Commit e56b61f

Browse files
committed
fix skills and issue templates
1 parent 15c94c4 commit e56b61f

7 files changed

Lines changed: 235 additions & 59 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ Before any implementation, collect all required information. If called from `iss
2929

3030
If any item is missing, ask the user to provide it. Do NOT proceed until the checklist is complete.
3131

32+
### Associated Rule Check
33+
34+
Before implementation, verify that at least one reduction rule exists or is planned for this problem — otherwise it will be an orphan node in the reduction graph.
35+
36+
**Check both directions:**
37+
38+
1. **Outbound (this issue → rule issues):** Look for rule issue numbers in the model issue's "Reduction Rule Crossref" section.
39+
2. **Inbound (rule issues → this problem):** Search open rule issues that reference this problem as source or target:
40+
```bash
41+
gh issue list --label rule --state open --limit 500 --json number,title | \
42+
jq '[.[] | select(.title | test("<ProblemName>"; "i"))]'
43+
```
44+
45+
**If no associated rules are found:**
46+
- Warn the user: "This model has no associated rule issues. It will be an orphan node in the reduction graph and will be flagged during review."
47+
- Ask whether to proceed anyway or file a companion rule issue first (via `/propose rule`).
48+
- If proceeding, add a visible `<!-- WARNING: orphan model — no associated rule issue -->` comment in the PR description.
49+
50+
**If associated rules are found:** List them and continue.
51+
3252
## Reference Implementations
3353

3454
Read these first to understand the patterns:

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

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,41 @@ Use `AskUserQuestion` to confirm:
102102
> - "I see an issue" — reviewer describes the problem
103103
> - "Skip" — skip this check
104104
105+
### Step 3b: File whitelist check
106+
107+
Check that the PR only touches files expected for its type. Any file outside the whitelist is flagged for review — it may be a legacy pattern or an unrelated change.
108+
109+
**Whitelist for [Model] PRs:**
110+
- `src/models/<category>/<name>.rs` — model implementation
111+
- `src/unit_tests/models/<category>/<name>.rs` — unit tests
112+
- `src/example_db/model_builders.rs` — canonical example registration
113+
- `src/example_db/rule_builders.rs` — only if updating nonempty-style assertions
114+
- `docs/paper/reductions.typ` — paper entry
115+
- `docs/src/reductions/problem_schemas.json` — schema export
116+
- `docs/src/reductions/reduction_graph.json` — graph export
117+
- `tests/suites/trait_consistency.rs` — trait consistency entry
118+
119+
**Whitelist for [Rule] PRs:**
120+
- `src/rules/<source>_<target>.rs` — reduction implementation
121+
- `src/rules/mod.rs` — module registration
122+
- `src/unit_tests/rules/<source>_<target>.rs` — unit tests
123+
- `src/example_db/rule_builders.rs` — canonical example registration
124+
- `src/models/<category>/<name>.rs` — only if adding getters needed for overhead expressions
125+
- `docs/paper/reductions.typ` — paper entry
126+
- `docs/src/reductions/reduction_graph.json` — graph export
127+
- `docs/src/reductions/problem_schemas.json` — only if updating field descriptions
128+
129+
If any file falls outside these whitelists, flag it:
130+
131+
> **File Whitelist Check**
132+
>
133+
> Found N file(s) outside expected whitelist:
134+
> - `path/to/file`[what it does, why it may not belong]
135+
>
136+
> These should be reviewed — they may follow a deprecated pattern or be unrelated to this PR.
137+
138+
If all files are whitelisted, report "All files within expected whitelist" and continue.
139+
105140
### Step 4: Completeness check
106141

107142
Verify the PR includes all required components. Check:
@@ -162,14 +197,16 @@ Present to reviewer:
162197
> Strengths:
163198
> - [bullet points]
164199
>
165-
> Weaknesses:
166-
> - [bullet points]
200+
> Weaknesses (numbered):
201+
> 1. [issue description — file:line if applicable]
202+
> 2. [issue description — file:line if applicable]
203+
> ...
167204
>
168205
> Comparable to: [name a similar-quality existing model/rule for reference]
169206
170207
### Step 6: Final decision
171208

172-
Summarize all findings and ask the reviewer for a decision.
209+
Summarize all findings and present the numbered issues as selectable options.
173210

174211
Present a summary table:
175212

@@ -181,13 +218,16 @@ Present a summary table:
181218
| Quality | [N%] |
182219
| PR URL | [link] |
183220

184-
Use `AskUserQuestion`:
221+
Then present all numbered issues from Step 5 as a multi-select `AskUserQuestion`:
222+
223+
> **Which issues should be fixed before merging?** (select all that apply, or "Merge as-is")
224+
> - "Merge as-is" — no fixes needed
225+
> - "Fix 1: [short description]" — [one-line summary]
226+
> - "Fix 2: [short description]" — [one-line summary]
227+
> - ...
228+
> - "OnHold" — move to OnHold column with a reason
185229
186-
> **What would you like to do with this PR?**
187-
> - "Merge" — approve and show merge link for browser
188-
> - "OnHold" — move to OnHold column with a reason comment
189-
> - "Quick fix" — fix specific issues before merging (describe what to fix)
190-
> - "Reject" — close the PR with explanation
230+
This lets the reviewer cherry-pick exactly which issues to fix. If the reviewer selects fixes, proceed to Step 7 Quick fix. If "Merge as-is", proceed to Step 7 Merge.
191231

192232
### Step 7: Execute decision
193233

@@ -208,7 +248,7 @@ Use `AskUserQuestion`:
208248
```
209249

210250
**If Quick fix:**
211-
1. Ask the reviewer what needs fixing (use `AskUserQuestion`).
251+
1. Apply only the fixes the reviewer selected in Step 6.
212252
2. Checkout the PR branch in a worktree, apply fixes, commit, push.
213253
3. After push, go back to Step 6 to re-confirm the decision.
214254

.claude/skills/propose/SKILL.md

Lines changed: 75 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ digraph propose {
3535
"Brainstorm Rule(s)" [shape=box];
3636
"Select rule pair" [shape=box];
3737
"Study models" [shape=box];
38-
"Well-known?" [shape=diamond];
39-
"Auto-fill from literature" [shape=box];
38+
"Literature check" [shape=diamond];
4039
"Guided brainstorming" [shape=box];
4140
"Present draft(s)" [shape=box];
4241
"Run check-issue on draft" [shape=box];
@@ -53,10 +52,8 @@ digraph propose {
5352
"Study conventions" -> "Brainstorm Model" [label="model"];
5453
"Study conventions" -> "Select rule pair" [label="rule"];
5554
"Select rule pair" -> "Study models";
56-
"Study models" -> "Well-known?";
57-
"Well-known?" -> "Auto-fill from literature" [label="yes — skip questions"];
58-
"Well-known?" -> "Guided brainstorming" [label="no — novel reduction"];
59-
"Auto-fill from literature" -> "Present draft(s)";
55+
"Study models" -> "Literature check";
56+
"Literature check" -> "Guided brainstorming" [label="pre-fill if found"];
6057
"Guided brainstorming" -> "Present draft(s)";
6158
"Brainstorm Model" -> "Topology analysis";
6259
"Topology analysis" -> "Propose rules?";
@@ -249,7 +246,7 @@ Work through these topics in order, using `AskUserQuestion` where multiple-choic
249246
description: "I'll describe the variable structure"
250247
```
251248

252-
4. **Complexity & Reference** — Before asking, use WebSearch to research the best known exact algorithms and canonical references for this problem. Then present 3 candidates via `AskUserQuestion`, each combining the complexity bound with its source:
249+
4. **Complexity & Reference** — Before asking, use WebSearch to research the best known exact algorithms and canonical references for this problem. Then present up to 3 candidates via `AskUserQuestion`, each combining the complexity bound with its source:
253250

254251
```
255252
AskUserQuestion:
@@ -296,7 +293,7 @@ Work through these topics in order, using `AskUserQuestion` where multiple-choic
296293

297294
**Important:** If the user chooses "Reduce to ILP" or "Reduce to QUBO", remind them that this requires a reduction rule issue. Either cross-reference an existing rule issue, or plan to file one as a companion rule (which will be proposed in Step 3b Topology Analysis). The model issue's "How to solve" section must reference the rule issue number.
298295

299-
6. **Example** — Generate 3 candidate examples yourself (varying in size and structure), then present via `AskUserQuestion`:
296+
6. **Example** — Generate **at least 3** candidate examples yourself (varying in size and structure), then present via `AskUserQuestion`. **3 options is the minimum — never fewer.** Always include a "Generate new batch" escape hatch:
300297

301298
```
302299
AskUserQuestion:
@@ -309,9 +306,13 @@ Work through these topics in order, using `AskUserQuestion` where multiple-choic
309306
description: "<brief description — exercises core structure>"
310307
- label: "<larger instance summary>"
311308
description: "<brief description — richer, more illustrative>"
309+
- label: "Generate new batch"
310+
description: "None of these work — generate a fresh set of examples"
312311
```
313312

314-
After the user picks one, provide a complete instance with its known optimal solution.
313+
If the user picks "Generate new batch", create 3 new examples with different sizes/structures and re-present.
314+
315+
After the user picks a concrete example, provide a complete instance with its known optimal solution.
315316
- Must exercise the problem's core structure
316317
- Must be small enough to verify by hand
317318

@@ -444,41 +445,68 @@ gh issue list --label rule --state open --json number,title | jq '.[] | select(.
444445

445446
This information is essential for writing correct overhead tables and identifying implementation concerns.
446447

447-
#### Step 3.3: Well-known reduction fast path
448+
#### Step 3.3: Literature check
448449

449-
After studying the models, determine whether this is a **well-known textbook reduction**:
450+
After studying the models, check whether this is a **well-known textbook reduction**:
450451
- Use WebSearch to check standard references (Garey & Johnson, Karp's 21, CLRS, Sipser, Arora & Barak)
451452
- Check if an existing GitHub issue already describes this reduction
452453

453-
**If the reduction is well-known** (found in at least one textbook or survey):
454-
- **Do NOT ask brainstorming questions** (motivation, algorithm, correctness, overhead, example, reference) — the answers are in the literature
455-
- Auto-fill every section by researching the literature and using the model data from Step 3.2
456-
- Jump directly to **Step 4: Present Draft Issue(s)**
457-
- The draft presentation is the user's review point — they can revise any section there
458-
459-
**If the reduction is NOT well-known** (novel or obscure):
460-
- Proceed to **Step 3.4: Guided brainstorming** below
461-
462-
> **Rationale:** Domain experts proposing a textbook reduction should not be quizzed on facts they already know. The skill's value is producing a well-formatted, correct issue — not asking obvious questions. For novel reductions, guided brainstorming helps the user think through the design.
454+
If the reduction is well-known, use the literature to **pre-fill** answers in Step 3.4 — but still present each step to the user for confirmation. Do NOT skip the guided brainstorming.
463455

464-
#### Step 3.4: Guided brainstorming (novel reductions only)
456+
#### Step 3.4: Guided brainstorming
465457

466-
Only reach this step if the reduction is novel or obscure. Work through these topics in order. **Do not use `AskUserQuestion` when the answer is determinable from topology analysis, model inspection, or literature search** — just auto-fill and note what you filled. Only ask when genuine user input is needed.
458+
**Always run this step**, whether the reduction is well-known or novel. For well-known reductions, pre-fill answers from literature and present them for confirmation. For novel reductions, ask the user to provide answers. Work through these topics in order, **one at a time**.
467459

468-
1. **Why useful?** — If the topology analysis already shows this connects an orphan, fills an NP-hardness gap, or provides a shorter path, **state the motivation directly** — do not ask. Only use `AskUserQuestion` if the motivation is genuinely ambiguous.
460+
1. **Why useful?** — State the motivation (e.g., connects orphan, fills NP-hardness gap) and present for confirmation via `AskUserQuestion`:
461+
```
462+
AskUserQuestion:
463+
question: "What's the main motivation for this reduction?"
464+
header: "Motivation"
465+
options:
466+
- label: "<inferred motivation> (Recommended)"
467+
description: "<why — e.g., connects orphan PaintShop to QUBO hub>"
468+
- label: "<alternative motivation>"
469+
description: "<why>"
470+
- label: "<alternative motivation>"
471+
description: "<why>"
472+
```
469473

470-
2. **Algorithm** — Ask as a free-text question (no multiple choice here):
471-
> "How does the reduction work? Given a source instance, how do you construct the target instance? Please describe step by step."
474+
2. **Algorithm** — Research the reduction algorithm (use WebSearch for well-known reductions, ask the user for novel ones). Present candidate approaches via `AskUserQuestion`:
475+
```
476+
AskUserQuestion:
477+
question: "Which reduction approach should we use?"
478+
header: "Algorithm"
479+
options:
480+
- label: "<approach 1> (Recommended)"
481+
description: "<brief summary of how it works>"
482+
- label: "<approach 2>"
483+
description: "<brief summary>"
484+
- label: "<approach 3>"
485+
description: "<brief summary>"
486+
```
487+
After the user picks one, present the full algorithm write-up for confirmation.
472488
- Must define all symbols before using them
473489
- Must be detailed enough that someone could implement it
474-
- If the user is unsure, use WebSearch to find known reductions in the literature
475490

476-
3. **Correctness** — Ask as free text:
477-
> "Why does this work? Why does an optimal solution to the target correspond to an optimal solution of the source?"
491+
3. **Explanation** — Present a correctness argument explaining why the reduction preserves optimal solutions, then ask for feedback via `AskUserQuestion`:
492+
```
493+
AskUserQuestion:
494+
question: "How does this explanation look?"
495+
header: "Explanation"
496+
options:
497+
- label: "Looks good"
498+
description: "The correctness argument is clear and complete"
499+
- label: "More detail"
500+
description: "Please expand the argument with more steps or formal reasoning"
501+
- label: "Less detail"
502+
description: "Too verbose — please shorten to the key insight"
503+
```
504+
If the user asks for more or less detail, revise and re-present.
478505

479-
4. **Size overhead** — Auto-fill from the algorithm description using the target's size fields from `pred show <target> --json`. Ask the user to confirm only if the overhead is unclear from the algorithm.
506+
4. **Size overhead** — Compute overhead from the algorithm using the target's size fields from `pred show <target> --json`. Present the overhead table and ask for confirmation:
507+
> "Based on the algorithm, the size overhead is: [table]. Does this look correct?"
480508
481-
5. **Example** — Generate 3 candidate examples yourself (varying in size and structure), then present via `AskUserQuestion`:
509+
5. **Example** — Generate **at least 3** candidate examples yourself (varying in size and structure), then present via `AskUserQuestion`. **3 options is the minimum — never fewer.** Always include a "Generate new batch" escape hatch:
482510

483511
```
484512
AskUserQuestion:
@@ -491,23 +519,30 @@ Only reach this step if the reduction is novel or obscure. Work through these to
491519
description: "<brief description — shows a non-obvious optimum>"
492520
- label: "<larger instance summary>"
493521
description: "<brief description — richer structure, more trade-offs>"
522+
- label: "Generate new batch"
523+
description: "None of these work — generate a fresh set of examples"
494524
```
495525

496-
After the user picks one, fully work out the example: show source instance, each construction step, resulting target instance, and the optimal solution.
526+
If the user picks "Generate new batch", create 3 new examples with different sizes/structures and re-present.
527+
528+
After the user picks a concrete example, fully work out the example: show source instance, each construction step, resulting target instance, and the optimal solution.
497529
- Must be non-trivial but hand-verifiable
498530
- Must exercise the core structure of the reduction
499531

500-
6. **Reference** — Use WebSearch to find references first. Only use `AskUserQuestion` if no reference is found:
532+
6. **Reference** — Use WebSearch to find references. Present candidate references via `AskUserQuestion`:
501533
```
502534
AskUserQuestion:
503-
question: "Is there a paper or textbook that describes this reduction?"
535+
question: "Which reference should we cite?"
504536
header: "Reference"
505537
options:
506-
- label: "Yes, I have a reference"
507-
description: "I'll provide the citation"
508-
- label: "This is a novel reduction"
509-
description: "I designed this myself — no existing reference"
538+
- label: "<reference 1> (Recommended)"
539+
description: "<paper title, year> — <URL>"
540+
- label: "<reference 2>"
541+
description: "<paper title, year> — <URL>"
542+
- label: "<reference 3>"
543+
description: "<paper title, year> — <URL>"
510544
```
545+
If no references are found, ask the user if this is a novel reduction.
511546

512547
---
513548

@@ -696,7 +731,7 @@ Print all issue URLs when done.
696731

697732
- **Use `AskUserQuestion` only when genuine user input is needed** — use it for choices where the answer is NOT determinable from context (type detection, problem selection, example selection, approval). Do NOT use it when the answer is already clear from topology analysis, model inspection, or literature (e.g., don't ask "why is this useful?" when the topology analysis already shows it connects an orphan).
698733
- **Study models before brainstorming** — always run `pred show <source> --json` and `pred show <target> --json` before asking questions. This reveals field types, size getters, and schema details that are essential for correct overhead tables.
699-
- **Fast-path well-known reductions** — if the reduction appears in standard textbooks, skip all brainstorming questions and auto-fill the draft from literature + model data. Present the draft directly for review.
734+
- **Pre-fill well-known reductions** — if the reduction appears in standard textbooks, pre-fill answers from literature but still present each step to the user for confirmation. Never skip brainstorming steps.
700735
- **One question at a time** — don't overwhelm; each `AskUserQuestion` call has one focused question
701736
- **Mathematical language only** — never mention Rust types, traits, macros, or code patterns to the user
702737
- **Help find references** — use WebSearch to help locate papers, verify claims
@@ -710,7 +745,7 @@ Print all issue URLs when done.
710745

711746
- **Don't ask questions with obvious answers.** If the topology analysis shows the rule connects an orphan, don't ask "What makes this reduction valuable?" — state it. Only use `AskUserQuestion` when the answer requires genuine user input.
712747
- **Don't skip model inspection.** Always run `pred show <source> --json` and `pred show <target> --json` before brainstorming. Missing this leads to wrong overhead tables and missed type mismatches (e.g., `BigUint` vs `i64`).
713-
- **Don't quiz users on textbook reductions.** If SubsetSum → Knapsack is in Garey & Johnson, don't ask the user to explain the algorithm step by step — look it up and draft the issue.
748+
- **Don't skip confirmation for textbook reductions.** Even if SubsetSum → Knapsack is in Garey & Johnson, still present each brainstorming step with pre-filled answers for the user to confirm or revise. Never jump straight to the draft.
714749
- **Don't rebuild `pred` unnecessarily.** Use `command -v pred` to check if it's installed before running `make cli` (which takes >1 minute).
715750
- **Don't ask all questions at once.** One `AskUserQuestion` call per message.
716751
- **Don't use programming jargon.** Say "list of weights" not "Vec<W>". Say "graph" not "SimpleGraph". Say "integer" not "i32".

0 commit comments

Comments
 (0)