Skip to content

Commit 3e193a7

Browse files
committed
fix skill, update AGENTS.md
1 parent 76fdaa7 commit 3e193a7

2 files changed

Lines changed: 127 additions & 57 deletions

File tree

.claude/skills/propose/SKILL.md

Lines changed: 113 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ digraph propose {
3333
"Topology analysis" [shape=box];
3434
"Propose rules?" [shape=diamond];
3535
"Brainstorm Rule(s)" [shape=box];
36-
"Brainstorm Rule (standalone)" [shape=box];
36+
"Select rule pair" [shape=box];
37+
"Study models" [shape=box];
38+
"Well-known?" [shape=diamond];
39+
"Auto-fill from literature" [shape=box];
40+
"Guided brainstorming" [shape=box];
3741
"Present draft(s)" [shape=box];
3842
"Run check-issue on draft" [shape=box];
3943
"Checks pass?" [shape=diamond];
@@ -47,13 +51,18 @@ digraph propose {
4751
"Detect type" -> "Study conventions" [label="model or rule"];
4852
"Detect type" -> "Start" [label="ask user"];
4953
"Study conventions" -> "Brainstorm Model" [label="model"];
50-
"Study conventions" -> "Brainstorm Rule (standalone)" [label="rule"];
54+
"Study conventions" -> "Select rule pair" [label="rule"];
55+
"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)";
60+
"Guided brainstorming" -> "Present draft(s)";
5161
"Brainstorm Model" -> "Topology analysis";
5262
"Topology analysis" -> "Propose rules?";
5363
"Propose rules?" -> "Brainstorm Rule(s)" [label="yes"];
5464
"Propose rules?" -> "Present draft(s)" [label="no, later"];
5565
"Brainstorm Rule(s)" -> "Present draft(s)";
56-
"Brainstorm Rule (standalone)" -> "Present draft(s)";
5766
"Present draft(s)" -> "Run check-issue on draft";
5867
"Run check-issue on draft" -> "Checks pass?";
5968
"Checks pass?" -> "Present draft(s)" [label="fix issues"];
@@ -116,13 +125,25 @@ Right after the user picks model or rule, **study at least one existing case** i
116125

117126
### For Rules
118127

119-
1. Ask the user a brief orienting question (free text):
120-
> "Which two problems are you thinking of connecting? Even a rough idea is fine."
128+
1. **Run topology analysis first** to identify the most impactful missing reductions, then present the top candidates as recommendations. Only ask the user an open-ended "which two problems?" question if they don't have a specific pair in mind — otherwise, use the topology data to populate `AskUserQuestion` options in Step 3.1 directly.
129+
130+
Run these commands silently before asking any questions:
131+
```bash
132+
# Core data (fast — uses pre-built pred binary)
133+
pred list --json
134+
gh issue list --label rule --state open --limit 500 --json number,title
121135

122-
2. Based on the answer, study one existing reduction between similar problems. Use `pred neighbors <source_or_target> --json` to find existing reductions, then pick the most relevant one and examine it:
136+
# Topology analysis (slower — compiles example binaries, but gives orphan/NP-hardness data)
137+
cargo run --example detect_isolated_problems 2>/dev/null
138+
cargo run --example detect_unreachable_from_3sat 2>/dev/null
139+
```
140+
Run the first two commands in parallel. The example binaries take longer but provide essential orphan/NP-hardness gap data for ranking recommendations.
141+
142+
2. Based on the topology results, study one existing reduction between similar problems. Use `pred to` and `pred from` to find existing reductions, then pick the most relevant one and examine it:
123143

124144
```bash
125-
pred neighbors <problem> --json
145+
pred to <problem> --json # problems that reduce TO this one (incoming)
146+
pred from <problem> --json # problems this reduces FROM (outgoing)
126147
```
127148

128149
Also find and read one closed `[Rule]` issue in a similar domain:
@@ -145,10 +166,12 @@ Right after the user picks model or rule, **study at least one existing case** i
145166

146167
## Step 2: Explore Context
147168

148-
Before asking questions, check what already exists. Try `pred`; if not available, build it first with `make cli`.
169+
Before asking questions, check what already exists. Use `pred` if it's already installed; only build if the command is missing.
149170

150171
```bash
151-
pred list --json 2>/dev/null || (make cli && pred list --json)
172+
# Only build if pred is not already installed — make cli takes >1 minute
173+
command -v pred >/dev/null 2>&1 || make cli
174+
pred list --json
152175
```
153176

154177
Also **search for existing GitHub issues** to avoid duplicates and surface related work:
@@ -370,62 +393,92 @@ After model brainstorming is complete, proceed to **Step 3b: Topology Analysis**
370393

371394
### For Rules (standalone)
372395

373-
Work through these topics in order, using `AskUserQuestion` for each step. (The orienting "Which two problems?" question was already asked in Step 1b, and conventions were studied.)
396+
Topology analysis was already run in Step 1b. Conventions were studied.
374397

375-
1. **Which problems?** — First run topology analysis (orphans, NP-hardness gaps, `pred list --json`) to identify the most needed rules. Incorporate what the user mentioned in Step 1b, then present suggestions via `AskUserQuestion`:
398+
#### Step 3.1: Recommend rules
376399

377-
```
378-
AskUserQuestion:
379-
question: "Which reduction would you like to propose?"
380-
header: "Reduction"
381-
options:
382-
- label: "<Source> → <Target> (Recommended)"
383-
description: "<why this is the most valuable — e.g., connects orphan, fills NP-hardness gap>"
384-
- label: "<Source> → <Target>"
385-
description: "<why valuable>"
386-
- label: "<Source> → <Target>"
387-
description: "<why valuable>"
388-
- label: "I have a different pair"
389-
description: "I'll describe the source and target problems"
390-
```
400+
Use the topology data from Step 1b to present **data-driven recommendations** via `AskUserQuestion`. The options should be populated from the analysis — do not ask the user to name problems before you have analyzed the graph.
391401

392-
Populate the suggestions based on topology analysis:
393-
- **Priority 1:** Rules that connect orphan problems (8 orphans: BMF, BicliqueCover, CVP, GraphPartitioning, Knapsack, MaximalIS, MinimumFeedbackVertexSet, PaintShop)
394-
- **Priority 2:** Rules that fill NP-hardness proof gaps (BinPacking, LongestCommonSubsequence, TravelingSalesman have no inbound path from 3-SAT)
395-
- **Priority 3:** Rules to large clusters (QUBO, ILP, SAT families)
402+
```
403+
AskUserQuestion:
404+
question: "Which reduction would you like to propose?"
405+
header: "Reduction"
406+
options:
407+
- label: "<Source> → <Target> (Recommended)"
408+
description: "<why most valuable — e.g., connects orphan X, proves NP-hardness, existing issue #N>"
409+
- label: "<Source> → <Target>"
410+
description: "<why valuable — note existing issues if any>"
411+
- label: "<Source> → <Target>"
412+
description: "<why valuable — note existing issues if any>"
413+
- label: "I have a different pair"
414+
description: "I'll describe the source and target problems"
415+
```
396416

397-
After selection, verify both problems exist (or one is being proposed alongside).
417+
**Selection criteria** (in priority order) — only suggest rules where **both source and target already exist** in the codebase:
418+
- **Priority 1:** Rules that connect orphan problems to the main component (check `detect_isolated_problems` output)
419+
- **Priority 2:** Rules that fill NP-hardness proof gaps (check `detect_unreachable_from_3sat` output)
420+
- **Priority 3:** Rules to large clusters (QUBO, ILP, SAT families)
421+
- **Filter:** Exclude pairs that already have a reduction registered **AND** pairs that already have an open GitHub issue filed (even if not yet implemented). Do not recommend duplicates — if an issue exists, it should be implemented via `/issue-to-pr`, not re-proposed.
398422

399-
2. **Why useful?** — Use `AskUserQuestion`:
400-
```
401-
AskUserQuestion:
402-
question: "What makes this reduction valuable?"
403-
header: "Motivation"
404-
options:
405-
- label: "Connects an isolated problem"
406-
description: "Links an orphan problem to the main graph"
407-
- label: "Enables a new solver"
408-
description: "Allows solving via the target problem's solvers (e.g., ILP, QUBO)"
409-
- label: "Proves NP-hardness"
410-
description: "Establishes hardness via a chain from 3-SAT"
411-
- label: "Shorter reduction path"
412-
description: "Provides a more efficient path than what currently exists"
413-
```
414-
Also check if a path already exists: `pred path <source> <target> --json`
423+
After selection, verify both problems exist (or one is being proposed alongside).
424+
425+
#### Step 3.2: Study source and target models
426+
427+
**Mandatory before any brainstorming.** Inspect both models in the codebase:
428+
429+
```bash
430+
pred show <source> --json
431+
pred show <target> --json
432+
```
433+
434+
Note internally (do not dump to the user):
435+
- Field names, types, and size getters for both problems
436+
- Whether source/target are optimization or satisfaction problems
437+
- Type mismatches (e.g., `BigUint` vs `i64`) that the reduction must handle
438+
- Existing reductions to/from both problems (use `pred to` and `pred from`)
439+
440+
Also check for existing GitHub issues for this specific pair:
441+
```bash
442+
gh issue list --label rule --state open --json number,title | jq '.[] | select(.title | test("<source>.*<target>"; "i"))'
443+
```
415444

416-
3. **Algorithm** — Ask as a free-text question (no multiple choice here):
445+
This information is essential for writing correct overhead tables and identifying implementation concerns.
446+
447+
#### Step 3.3: Well-known reduction fast path
448+
449+
After studying the models, determine whether this is a **well-known textbook reduction**:
450+
- Use WebSearch to check standard references (Garey & Johnson, Karp's 21, CLRS, Sipser, Arora & Barak)
451+
- Check if an existing GitHub issue already describes this reduction
452+
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.
463+
464+
#### Step 3.4: Guided brainstorming (novel reductions only)
465+
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.
467+
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.
469+
470+
2. **Algorithm** — Ask as a free-text question (no multiple choice here):
417471
> "How does the reduction work? Given a source instance, how do you construct the target instance? Please describe step by step."
418472
- Must define all symbols before using them
419473
- Must be detailed enough that someone could implement it
420474
- If the user is unsure, use WebSearch to find known reductions in the literature
421475

422-
4. **Correctness** — Ask as free text:
476+
3. **Correctness** — Ask as free text:
423477
> "Why does this work? Why does an optimal solution to the target correspond to an optimal solution of the source?"
424478
425-
5. **Size overhead** — Ask as free text:
426-
> "How large is the target instance relative to the source? E.g., if the source has n vertices and m edges, how many variables/constraints does the target have?"
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.
427480

428-
6. **Example** — Generate 3 candidate examples yourself (varying in size and structure), then present via `AskUserQuestion`:
481+
5. **Example** — Generate 3 candidate examples yourself (varying in size and structure), then present via `AskUserQuestion`:
429482

430483
```
431484
AskUserQuestion:
@@ -444,16 +497,14 @@ Work through these topics in order, using `AskUserQuestion` for each step. (The
444497
- Must be non-trivial but hand-verifiable
445498
- Must exercise the core structure of the reduction
446499

447-
7. **Reference** — Use `AskUserQuestion`:
500+
6. **Reference** — Use WebSearch to find references first. Only use `AskUserQuestion` if no reference is found:
448501
```
449502
AskUserQuestion:
450503
question: "Is there a paper or textbook that describes this reduction?"
451504
header: "Reference"
452505
options:
453506
- label: "Yes, I have a reference"
454507
description: "I'll provide the citation"
455-
- label: "No, please help find one"
456-
description: "Search the literature for a known reduction"
457508
- label: "This is a novel reduction"
458509
description: "I designed this myself — no existing reference"
459510
```
@@ -474,7 +525,7 @@ cargo run --example detect_unreachable_from_3sat 2>/dev/null
474525
# List existing problems and reductions
475526
pred list --json
476527

477-
# Check if paths exist between the new problem's likely neighbors
528+
# Check if paths exist between the new problem's likely reduction targets
478529
pred path <similar_problem_A> <similar_problem_B> --json
479530
```
480531

@@ -643,7 +694,9 @@ Print all issue URLs when done.
643694

644695
## Key Principles
645696

646-
- **Use `AskUserQuestion` for structured choices** — whenever the user needs to pick from options (type detection, problem selection, motivation, variable type, data structure, reference type, approval), use the `AskUserQuestion` tool with well-labeled options. Use free text only for open-ended questions (algorithm description, formal definitions, examples, complexity expressions).
697+
- **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).
698+
- **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.
647700
- **One question at a time** — don't overwhelm; each `AskUserQuestion` call has one focused question
648701
- **Mathematical language only** — never mention Rust types, traits, macros, or code patterns to the user
649702
- **Help find references** — use WebSearch to help locate papers, verify claims
@@ -655,8 +708,11 @@ Print all issue URLs when done.
655708

656709
## Common Mistakes
657710

711+
- **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.
712+
- **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.
714+
- **Don't rebuild `pred` unnecessarily.** Use `command -v pred` to check if it's installed before running `make cli` (which takes >1 minute).
658715
- **Don't ask all questions at once.** One `AskUserQuestion` call per message.
659-
- **Don't use plain text for structured choices.** If the user needs to pick from options, use `AskUserQuestion` — not a bulleted list in plain text.
660716
- **Don't use programming jargon.** Say "list of weights" not "Vec<W>". Say "graph" not "SimpleGraph". Say "integer" not "i32".
661717
- **Don't skip the reduction crossref.** An orphan model will be rejected.
662718
- **Don't file without user approval.** Always show the draft first.

AGENTS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# AGENTS.md
2+
3+
The canonical agent instructions for this repository live in [`./.claude/CLAUDE.md`](./.claude/CLAUDE.md).
4+
5+
All agents should read and follow that file before making changes.
6+
7+
Use `./.claude/CLAUDE.md` as the source of truth for:
8+
- project workflow
9+
- commands and verification expectations
10+
- safety rules
11+
- architecture and testing conventions
12+
- repo-local skills under `./.claude/skills/`
13+
14+
Do not duplicate or fork those instructions here. Update `./.claude/CLAUDE.md` instead.

0 commit comments

Comments
 (0)