From 23d2cce2dce3b6febfc31e456ed5e8369f1d90b8 Mon Sep 17 00:00:00 2001 From: Pawel Polewicz Date: Sun, 8 Mar 2026 13:06:06 +0000 Subject: [PATCH 1/7] Add /fix and /ship Claude Code skills for automated lint, test, and ship workflow Co-Authored-By: Claude Opus 4.6 --- .claude/skills/fix.md | 45 ++++++++++++++++++++ .claude/skills/ship.md | 94 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 .claude/skills/fix.md create mode 100644 .claude/skills/ship.md diff --git a/.claude/skills/fix.md b/.claude/skills/fix.md new file mode 100644 index 0000000000..15d8adebf9 --- /dev/null +++ b/.claude/skills/fix.md @@ -0,0 +1,45 @@ +--- +name: fix +description: Commit changes, run Rust fix tools, run tests, and amend with any fixes +--- + +# Fix Skill + +Commit current changes with a descriptive message, then run Rust fix tools one by one, amending the commit after each tool if it produced changes, then run unit tests and fix any failures. + +## Steps + +1. **Initial commit**: Stage all changes and create a commit with a descriptive message summarizing the changes (use `git add -A && git commit -m ""`). If there are no changes to commit, create no commit but still proceed with the fix tools below. + +2. **Run each fix tool in order**. After EACH tool, check `git status --porcelain` for changes. If there are changes, stage them and amend the commit (`git add -A && git commit --amend --no-edit`). + + The tools to run in order: + + a. `cargo check --workspace` + b. `cargo clippy --fix --workspace --all-features --all-targets --allow-dirty` + c. `cargo fix --workspace --all-features --all-targets --allow-dirty` + d. `cargo fmt --all` + +3. **Run unit tests in a Sonnet subagent**: Launch a Task subagent (subagent_type: `general-purpose`, model: `sonnet`) that runs: + ``` + cargo test -p pallet-subtensor --lib + ``` + The subagent must: + - Run the test command and capture full output. + - If all tests pass, report success and return. + - If any tests fail, analyze the failures: read the failing test code AND the source code it tests, determine the root cause, apply fixes using Edit tools, and re-run the tests to confirm the fix works. + - After fixing, if there are further failures, repeat (up to 3 fix-and-retest cycles). + - Return a summary of: which tests failed, what was fixed, and whether all tests pass now. + +4. **Amend commit with test fixes**: After the subagent returns, if any code changes were made (check `git status --porcelain`), stage and amend the commit (`git add -A && git commit --amend --no-edit`). Then re-run the fix tools from step 2 (since code changes from test fixes may need formatting/clippy cleanup), amending after each if there are changes. + +5. **Final output**: Show `git log --oneline -1` so the user can see the resulting commit. + +## Important + +- Use `--allow-dirty` flags on clippy --fix and cargo fix since the working tree may have unstaged changes between steps. +- If a fix tool fails (step 2/4), stop and report the error to the user rather than continuing. +- Do NOT run `scripts/fix_rust.sh` itself — run the individual commands listed above instead. +- Do NOT skip any step. Run all four fix tools even if earlier ones produced no changes. +- The test subagent must fix source code to make tests pass, NOT modify tests to make them pass (unless the test itself is clearly wrong). +- If the test subagent cannot fix all failures after 3 cycles, it must return the remaining failures so the main agent can report them to the user. diff --git a/.claude/skills/ship.md b/.claude/skills/ship.md new file mode 100644 index 0000000000..58ca7e0e32 --- /dev/null +++ b/.claude/skills/ship.md @@ -0,0 +1,94 @@ +--- +name: ship +description: Ship the current branch: fix, push, create PR, watch CI, fix failures, code review +--- + +# Ship Skill + +Ship the current branch: fix, push, create PR if needed, watch CI, fix failures, and perform code review. + +## Phase 1: Fix and Push + +1. **Run `/fix`** — invoke the fix skill to commit, lint, and format. +2. **Push the branch** to origin: `git push -u origin HEAD`. +3. **Create a PR if none exists**: + - Check: `gh pr view --json number 2>/dev/null` — if it fails, no PR exists yet. + - If no PR exists, create one: + - Use `git log main..HEAD --oneline` to understand all commits on the branch. + - Read the changed files with `git diff main...HEAD --stat` to understand scope. + - Create the PR with `gh pr create --title "" --body "" --label "skip-cargo-audit"`. + - The description must include: a **Summary** section (bullet points of what changed and why), a **Changes** section (key files/modules affected), and a **Test plan** section. + - If a PR already exists, just note its number/URL. + +## Phase 2: Watch CI and Fix Failures + +4. **Poll CI status** in a loop: + - Run: `gh pr checks --json name,state,conclusion,link --watch --fail-fast 2>/dev/null || gh pr checks` + - If `--watch` is not available, poll manually every 90 seconds using `gh pr checks --json name,state,conclusion,link` until all checks have completed (no checks with state "pending" or conclusion ""). + - **Ignore these known-flaky/irrelevant checks** — treat them as passing even if they fail: + - `validate-benchmarks` (benchmark CI — not relevant) + - Any `Contract E2E Tests` check that failed only due to a timeout (look for timeout in the failure link/logs) + - `cargo-audit` (we already added the skip label) + - Also ignore any checks related to `check-spec-version` and `e2e` tests — these are environment-dependent and not fixable from code. + +5. **If there are real CI failures** (failures NOT in the ignore list above): + - For EACH distinct failing check, launch a **separate Task subagent** (subagent_type: `general-purpose`, model: `sonnet`) in parallel. Each subagent must: + - Fetch the failed check's logs: use `gh run view --log-failed` or the check link to get failure details. + - Investigate the root cause by reading relevant source files. + - Return a **fix plan**: a description of what needs to change and in which files, with specific code snippets showing the fix. + - **Wait for all subagents** to return their fix plans. + +6. **Aggregate and apply fixes**: + - Review all returned fix plans for conflicts or overlaps. + - Apply the fixes using Edit/Write tools. + - Run `/fix` again (invoke the fix skill) to commit, lint, and format the fixes. + - Push: `git push`. + +7. **Re-check CI**: Go back to step 4 and poll again. Repeat the fix cycle up to **3 times**. If CI still fails after 3 rounds, report the remaining failures to the user and stop. + +## Phase 3: Code Review + +8. **Once CI is green** (or only ignored checks are failing), perform a thorough code review. + +9. **Launch a single Opus subagent** (subagent_type: `general-purpose`, model: `opus`) for the review: + - It must get the full PR diff: `git diff main...HEAD`. + - It must read every changed file in full. + - It must produce a numbered list of **issues** found, where each issue has: + - A unique sequential ID (e.g., `R-1`, `R-2`, ...). + - **Severity**: critical / major / minor / nit. + - **File and line(s)** affected. + - **Description** of the problem. + - The review must check for: correctness, safety (no panics, no unchecked arithmetic, no indexing), edge cases, naming, documentation gaps, test coverage, and adherence to Substrate/Rust best practices. + - Return the full list of issues. + +10. **For each issue**, launch TWO subagents **in parallel**: + - **Fix designer** (subagent_type: `general-purpose`, model: `sonnet`): Given the issue description and relevant code context, design a concrete proposed fix with exact code changes (old code -> new code). Return the fix as a structured plan. + - **Fix reviewer** (subagent_type: `general-purpose`, model: `opus`): Given the issue description, the relevant code context, and the proposed fix (once the fix designer returns — so the reviewer runs AFTER the designer, but reviewers for different issues run in parallel with each other). The reviewer must check: + - Does the fix actually solve the issue? + - Does it introduce new problems? + - Is it the simplest correct fix? + - Return: approved / rejected with reasoning. + + Implementation note: For each issue, first launch the fix designer. Once the fix designer for that issue returns, launch the fix reviewer for that issue. But all issues should be processed in parallel — i.e., launch all fix designers at once, then as each designer returns, launch its corresponding reviewer. You may batch reviewers if designers finish close together. + +11. **Report to user**: Present a formatted summary: + ``` + ## Code Review Results + + ### R-1: [severity] + **File**: path/to/file.rs:42 + **Issue**: <description> + **Proposed fix**: <summary of fix> + **Review**: Approved / Rejected — <reasoning> + + ### R-2: ... + ``` + Ask the user which fixes to apply (all approved ones, specific ones by ID, or none). + +## Important Rules + +- Never force-push. Always use regular `git push`. +- All CI polling must have a maximum total wall-clock timeout of 45 minutes. If CI hasn't finished by then, report current status and stop waiting. +- When fetching CI logs, if `gh run view` output is very long, focus on the failed step output only. +- Do NOT apply code review fixes automatically — always present them for user approval first. +- Use HEREDOC syntax for PR body and commit messages to preserve formatting. From 093a7fa91b61043a5377a0db133281a00f360e7c Mon Sep 17 00:00:00 2001 From: Pawel Polewicz <p.polewicz@gmail.com> Date: Thu, 12 Feb 2026 23:39:49 +0000 Subject: [PATCH 2/7] Fix skills location --- .claude/skills/{fix.md => fix/SKILL.md} | 0 .claude/skills/{ship.md => ship/SKILL.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .claude/skills/{fix.md => fix/SKILL.md} (100%) rename .claude/skills/{ship.md => ship/SKILL.md} (100%) diff --git a/.claude/skills/fix.md b/.claude/skills/fix/SKILL.md similarity index 100% rename from .claude/skills/fix.md rename to .claude/skills/fix/SKILL.md diff --git a/.claude/skills/ship.md b/.claude/skills/ship/SKILL.md similarity index 100% rename from .claude/skills/ship.md rename to .claude/skills/ship/SKILL.md From 90fb2ed78c04703f32010160d3dbf2e2e51bd243 Mon Sep 17 00:00:00 2001 From: Pawel Polewicz <p.polewicz@gmail.com> Date: Wed, 25 Mar 2026 20:03:41 +0000 Subject: [PATCH 3/7] Distill fix/ship skill descriptions and opening guidance --- .claude/skills/fix/SKILL.md | 4 ++-- .claude/skills/ship/SKILL.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.claude/skills/fix/SKILL.md b/.claude/skills/fix/SKILL.md index 15d8adebf9..4fac13c956 100644 --- a/.claude/skills/fix/SKILL.md +++ b/.claude/skills/fix/SKILL.md @@ -1,11 +1,11 @@ --- name: fix -description: Commit changes, run Rust fix tools, run tests, and amend with any fixes +description: Commit current changes, run Rust autofix/lint/format, run pallet-subtensor tests, amend with any fixes. --- # Fix Skill -Commit current changes with a descriptive message, then run Rust fix tools one by one, amending the commit after each tool if it produced changes, then run unit tests and fix any failures. +Create or reuse one commit, run the Rust fix pipeline in order, run unit tests, and fold all resulting changes into that same commit. ## Steps diff --git a/.claude/skills/ship/SKILL.md b/.claude/skills/ship/SKILL.md index 58ca7e0e32..b2b70de7f6 100644 --- a/.claude/skills/ship/SKILL.md +++ b/.claude/skills/ship/SKILL.md @@ -1,11 +1,11 @@ --- name: ship -description: Ship the current branch: fix, push, create PR, watch CI, fix failures, code review +description: Ship current branch end-to-end: run /fix, push, open/update PR, triage CI failures, then deliver review findings for approval. --- # Ship Skill -Ship the current branch: fix, push, create PR if needed, watch CI, fix failures, and perform code review. +Ship the branch through CI and review without force-pushes, and never apply review fixes without explicit user approval. ## Phase 1: Fix and Push From 148287c6fb4ea9a1cab412ec3efbc4214d99e71c Mon Sep 17 00:00:00 2001 From: Pawel Polewicz <p.polewicz@gmail.com> Date: Wed, 25 Mar 2026 20:58:51 +0000 Subject: [PATCH 4/7] hand-tweak /fix and /format --- .claude/skills/fix/SKILL.md | 50 +++++++++++++--------------------- .claude/skills/format/SKILL.md | 25 +++++++++++++++++ 2 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 .claude/skills/format/SKILL.md diff --git a/.claude/skills/fix/SKILL.md b/.claude/skills/fix/SKILL.md index 4fac13c956..8f23de95aa 100644 --- a/.claude/skills/fix/SKILL.md +++ b/.claude/skills/fix/SKILL.md @@ -9,37 +9,25 @@ Create or reuse one commit, run the Rust fix pipeline in order, run unit tests, ## Steps -1. **Initial commit**: Stage all changes and create a commit with a descriptive message summarizing the changes (use `git add -A && git commit -m "<descriptive message>"`). If there are no changes to commit, create no commit but still proceed with the fix tools below. - -2. **Run each fix tool in order**. After EACH tool, check `git status --porcelain` for changes. If there are changes, stage them and amend the commit (`git add -A && git commit --amend --no-edit`). - - The tools to run in order: - - a. `cargo check --workspace` - b. `cargo clippy --fix --workspace --all-features --all-targets --allow-dirty` - c. `cargo fix --workspace --all-features --all-targets --allow-dirty` - d. `cargo fmt --all` - -3. **Run unit tests in a Sonnet subagent**: Launch a Task subagent (subagent_type: `general-purpose`, model: `sonnet`) that runs: - ``` - cargo test -p pallet-subtensor --lib - ``` - The subagent must: - - Run the test command and capture full output. - - If all tests pass, report success and return. - - If any tests fail, analyze the failures: read the failing test code AND the source code it tests, determine the root cause, apply fixes using Edit tools, and re-run the tests to confirm the fix works. - - After fixing, if there are further failures, repeat (up to 3 fix-and-retest cycles). - - Return a summary of: which tests failed, what was fixed, and whether all tests pass now. - -4. **Amend commit with test fixes**: After the subagent returns, if any code changes were made (check `git status --porcelain`), stage and amend the commit (`git add -A && git commit --amend --no-edit`). Then re-run the fix tools from step 2 (since code changes from test fixes may need formatting/clippy cleanup), amending after each if there are changes. - -5. **Final output**: Show `git log --oneline -1` so the user can see the resulting commit. +1. Run /format +2. In a Sonnet subagent run: + - `cargo test -p pallet-subtensor --lib` and capture full output + - If any tests fail, analyze the failures + - Read the failing test code AND the source code it tests + - Determine the root cause + - Apply fixes using Edit tools + - Re-run the tests to confirm the fix works + - After fixing, if there are further failures, repeat (up to 3 fix-and-retest cycles) + - Summarize: + - Which tests failed, if any + - What was fixed and how + - Whether all tests pass now +3. Amend commit with test fixes, if any, then /format +4. Run `git show -s` for user to review ## Important -- Use `--allow-dirty` flags on clippy --fix and cargo fix since the working tree may have unstaged changes between steps. -- If a fix tool fails (step 2/4), stop and report the error to the user rather than continuing. -- Do NOT run `scripts/fix_rust.sh` itself — run the individual commands listed above instead. -- Do NOT skip any step. Run all four fix tools even if earlier ones produced no changes. -- The test subagent must fix source code to make tests pass, NOT modify tests to make them pass (unless the test itself is clearly wrong). -- If the test subagent cannot fix all failures after 3 cycles, it must return the remaining failures so the main agent can report them to the user. +- Do NOT run `scripts/fix_rust.sh` — let /format take care of it +- Do NOT skip any steps +- The test subagent must fix source code to make tests pass, NOT modify tests to make them pass (unless the test itself is clearly wrong) +- If the test subagent cannot fix all failures after 3 cycles, it must return the remaining failures so the main agent can report them to the user diff --git a/.claude/skills/format/SKILL.md b/.claude/skills/format/SKILL.md new file mode 100644 index 0000000000..363370d260 --- /dev/null +++ b/.claude/skills/format/SKILL.md @@ -0,0 +1,25 @@ +--- +name: format +description: Commit current changes, run Rust autofix/lint/format, amend with any fixes. +--- + +# Format Skill + +Create or reuse one commit, run the Rust fix pipeline in order and fold all resulting changes into that same commit. + +## Steps + +1. Stage all changes and create a commit with a descriptive message summarizing the changes +2. Do this: + a. Run `cargo check --workspace` + b. Run `cargo clippy --fix --workspace --all-features --all-targets --allow-dirty` + c. Run `cargo fix --workspace --all-features --all-targets --allow-dirty` + d. Run `cargo fmt --all` + e. Amend the commit with any changes +3. Run `git show -s` for user to review + +## Important + +- If a fix tool fails in step 2, stop and report the error to the user rather than continuing +- Do NOT run `scripts/fix_rust.sh` itself — run the individual commands listed above instead +- Do NOT skip any steps From b93f415885895ef61d3afdb2aac07f2ba47f8437 Mon Sep 17 00:00:00 2001 From: Pawel Polewicz <p.polewicz@gmail.com> Date: Fri, 27 Mar 2026 17:15:30 +0000 Subject: [PATCH 5/7] hand-tweak /ship --- .claude/skills/ship/SKILL.md | 62 +++++++++++++----------------------- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/.claude/skills/ship/SKILL.md b/.claude/skills/ship/SKILL.md index b2b70de7f6..9e6400bd28 100644 --- a/.claude/skills/ship/SKILL.md +++ b/.claude/skills/ship/SKILL.md @@ -7,61 +7,43 @@ description: Ship current branch end-to-end: run /fix, push, open/update PR, tri Ship the branch through CI and review without force-pushes, and never apply review fixes without explicit user approval. -## Phase 1: Fix and Push +Run the following skill in a subagent to prevent context pollution. Make the subagent return a short summary to the main agent. -1. **Run `/fix`** — invoke the fix skill to commit, lint, and format. -2. **Push the branch** to origin: `git push -u origin HEAD`. -3. **Create a PR if none exists**: - - Check: `gh pr view --json number 2>/dev/null` — if it fails, no PR exists yet. - - If no PR exists, create one: - - Use `git log main..HEAD --oneline` to understand all commits on the branch. - - Read the changed files with `git diff main...HEAD --stat` to understand scope. - - Create the PR with `gh pr create --title "<concise title>" --body "<detailed markdown description>" --label "skip-cargo-audit"`. - - The description must include: a **Summary** section (bullet points of what changed and why), a **Changes** section (key files/modules affected), and a **Test plan** section. - - If a PR already exists, just note its number/URL. - -## Phase 2: Watch CI and Fix Failures - -4. **Poll CI status** in a loop: +1. Run `/fix` +2. Push the branch to origin +3. Create a PR with a comprehensive description if none exists yet + - Update the description if PR exists already +4. Poll CI status in a loop: - Run: `gh pr checks --json name,state,conclusion,link --watch --fail-fast 2>/dev/null || gh pr checks` - If `--watch` is not available, poll manually every 90 seconds using `gh pr checks --json name,state,conclusion,link` until all checks have completed (no checks with state "pending" or conclusion ""). - **Ignore these known-flaky/irrelevant checks** — treat them as passing even if they fail: - `validate-benchmarks` (benchmark CI — not relevant) - Any `Contract E2E Tests` check that failed only due to a timeout (look for timeout in the failure link/logs) - - `cargo-audit` (we already added the skip label) - - Also ignore any checks related to `check-spec-version` and `e2e` tests — these are environment-dependent and not fixable from code. - + - `cargo-audit` 5. **If there are real CI failures** (failures NOT in the ignore list above): - For EACH distinct failing check, launch a **separate Task subagent** (subagent_type: `general-purpose`, model: `sonnet`) in parallel. Each subagent must: - Fetch the failed check's logs: use `gh run view <run-id> --log-failed` or the check link to get failure details. - Investigate the root cause by reading relevant source files. - Return a **fix plan**: a description of what needs to change and in which files, with specific code snippets showing the fix. - **Wait for all subagents** to return their fix plans. - 6. **Aggregate and apply fixes**: - Review all returned fix plans for conflicts or overlaps. - Apply the fixes using Edit/Write tools. - - Run `/fix` again (invoke the fix skill) to commit, lint, and format the fixes. - - Push: `git push`. - + - Invoke the /fix skill + - `git push` 7. **Re-check CI**: Go back to step 4 and poll again. Repeat the fix cycle up to **3 times**. If CI still fails after 3 rounds, report the remaining failures to the user and stop. - -## Phase 3: Code Review - 8. **Once CI is green** (or only ignored checks are failing), perform a thorough code review. - -9. **Launch a single Opus subagent** (subagent_type: `general-purpose`, model: `opus`) for the review: - - It must get the full PR diff: `git diff main...HEAD`. - - It must read every changed file in full. - - It must produce a numbered list of **issues** found, where each issue has: - - A unique sequential ID (e.g., `R-1`, `R-2`, ...). - - **Severity**: critical / major / minor / nit. - - **File and line(s)** affected. - - **Description** of the problem. - - The review must check for: correctness, safety (no panics, no unchecked arithmetic, no indexing), edge cases, naming, documentation gaps, test coverage, and adherence to Substrate/Rust best practices. - - Return the full list of issues. - -10. **For each issue**, launch TWO subagents **in parallel**: + - **Launch a single Opus subagent** (subagent_type: `general-purpose`, model: `opus`) for the review: + - It must get the full PR diff: `git diff main...HEAD`. + - It must read every changed file in full. + - It must produce a numbered list of **issues** found, where each issue has: + - A unique sequential ID (e.g., `R-1`, `R-2`, ...). + - **Severity**: critical / major / minor / nit. + - **File and line(s)** affected. + - **Description** of the problem. + - The review must check for: correctness, safety (no panics, no unchecked arithmetic, no indexing), edge cases, naming, documentation gaps, test coverage, and adherence to Substrate/Rust best practices. + - Return the full list of issues. +9. **For each issue**, launch TWO subagents **in parallel**: - **Fix designer** (subagent_type: `general-purpose`, model: `sonnet`): Given the issue description and relevant code context, design a concrete proposed fix with exact code changes (old code -> new code). Return the fix as a structured plan. - **Fix reviewer** (subagent_type: `general-purpose`, model: `opus`): Given the issue description, the relevant code context, and the proposed fix (once the fix designer returns — so the reviewer runs AFTER the designer, but reviewers for different issues run in parallel with each other). The reviewer must check: - Does the fix actually solve the issue? @@ -71,7 +53,7 @@ Ship the branch through CI and review without force-pushes, and never apply revi Implementation note: For each issue, first launch the fix designer. Once the fix designer for that issue returns, launch the fix reviewer for that issue. But all issues should be processed in parallel — i.e., launch all fix designers at once, then as each designer returns, launch its corresponding reviewer. You may batch reviewers if designers finish close together. -11. **Report to user**: Present a formatted summary: +10. **Report to user**: Present a formatted summary: ``` ## Code Review Results @@ -89,6 +71,6 @@ Ship the branch through CI and review without force-pushes, and never apply revi - Never force-push. Always use regular `git push`. - All CI polling must have a maximum total wall-clock timeout of 45 minutes. If CI hasn't finished by then, report current status and stop waiting. -- When fetching CI logs, if `gh run view` output is very long, focus on the failed step output only. +- When fetching CI logs, use a subagent to isolate the relevant part. If `gh run view` output is very long, focus on the failed step output only. - Do NOT apply code review fixes automatically — always present them for user approval first. - Use HEREDOC syntax for PR body and commit messages to preserve formatting. From de5a77d3582c0bf1f1f7a8f52966f63e845c0dd4 Mon Sep 17 00:00:00 2001 From: Pawel Polewicz <p.polewicz@gmail.com> Date: Fri, 27 Mar 2026 19:18:08 +0000 Subject: [PATCH 6/7] Add CLAUDE.md --- .claude/skills/fix/SKILL.md | 18 +++++++++--------- .claude/skills/format/SKILL.md | 2 +- .claude/skills/ship/SKILL.md | 3 ++- CLAUDE.md | 4 ++++ 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 CLAUDE.md diff --git a/.claude/skills/fix/SKILL.md b/.claude/skills/fix/SKILL.md index 8f23de95aa..d097f3fbfe 100644 --- a/.claude/skills/fix/SKILL.md +++ b/.claude/skills/fix/SKILL.md @@ -10,18 +10,18 @@ Create or reuse one commit, run the Rust fix pipeline in order, run unit tests, ## Steps 1. Run /format -2. In a Sonnet subagent run: +2. In a subagent (subagent_type: `general-purpose`, model: `sonnet`) run: - `cargo test -p pallet-subtensor --lib` and capture full output - If any tests fail, analyze the failures - - Read the failing test code AND the source code it tests - - Determine the root cause - - Apply fixes using Edit tools - - Re-run the tests to confirm the fix works - - After fixing, if there are further failures, repeat (up to 3 fix-and-retest cycles) + - Read the failing test code AND the source code it tests + - Determine the root cause + - Apply fixes using Edit tools + - Re-run the tests to confirm the fix works + - After fixing, if there are further failures, repeat (up to 3 fix-and-retest cycles) - Summarize: - - Which tests failed, if any - - What was fixed and how - - Whether all tests pass now + - Which tests failed, if any + - What was fixed and how + - Whether all tests pass now 3. Amend commit with test fixes, if any, then /format 4. Run `git show -s` for user to review diff --git a/.claude/skills/format/SKILL.md b/.claude/skills/format/SKILL.md index 363370d260..9a0424b28b 100644 --- a/.claude/skills/format/SKILL.md +++ b/.claude/skills/format/SKILL.md @@ -9,7 +9,7 @@ Create or reuse one commit, run the Rust fix pipeline in order and fold all resu ## Steps -1. Stage all changes and create a commit with a descriptive message summarizing the changes +1. Stage all changes and create a commit with a descriptive message summarizing the changes (unless there are none) 2. Do this: a. Run `cargo check --workspace` b. Run `cargo clippy --fix --workspace --all-features --all-targets --allow-dirty` diff --git a/.claude/skills/ship/SKILL.md b/.claude/skills/ship/SKILL.md index 9e6400bd28..163015b8b2 100644 --- a/.claude/skills/ship/SKILL.md +++ b/.claude/skills/ship/SKILL.md @@ -13,6 +13,7 @@ Run the following skill in a subagent to prevent context pollution. Make the sub 2. Push the branch to origin 3. Create a PR with a comprehensive description if none exists yet - Update the description if PR exists already + - Add label `skip-cargo-audit` to the PR 4. Poll CI status in a loop: - Run: `gh pr checks --json name,state,conclusion,link --watch --fail-fast 2>/dev/null || gh pr checks` - If `--watch` is not available, poll manually every 90 seconds using `gh pr checks --json name,state,conclusion,link` until all checks have completed (no checks with state "pending" or conclusion ""). @@ -43,7 +44,7 @@ Run the following skill in a subagent to prevent context pollution. Make the sub - **Description** of the problem. - The review must check for: correctness, safety (no panics, no unchecked arithmetic, no indexing), edge cases, naming, documentation gaps, test coverage, and adherence to Substrate/Rust best practices. - Return the full list of issues. -9. **For each issue**, launch TWO subagents **in parallel**: +9. **For each issue**, run fix designer then fix reviewer in sequence; run all issues concurrently with each other: - **Fix designer** (subagent_type: `general-purpose`, model: `sonnet`): Given the issue description and relevant code context, design a concrete proposed fix with exact code changes (old code -> new code). Return the fix as a structured plan. - **Fix reviewer** (subagent_type: `general-purpose`, model: `opus`): Given the issue description, the relevant code context, and the proposed fix (once the fix designer returns — so the reviewer runs AFTER the designer, but reviewers for different issues run in parallel with each other). The reviewer must check: - Does the fix actually solve the issue? diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000000..2b6da8644e --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,4 @@ +- never use slice indexing like `arr[n..]` or `arr[i]`; use `.get(n..)`, `.get(i)` etc. instead to avoid panics (clippy::indexing_slicing) +- never use `*`, `+`, `-`, `/` for arithmetic; use `.saturating_mul()`, `.saturating_add()`, `.saturating_sub()`, `.saturating_div()` or checked variants instead (clippy::arithmetic_side_effects) +- if you are creating a PR to `subtensor` add a `skip-cargo-audit` label +- no `Co-Authored-By` in commits From 331f4e449771425c83ef1b449eabb4d83e92c7a9 Mon Sep 17 00:00:00 2001 From: Pawel Polewicz <p.polewicz@gmail.com> Date: Fri, 27 Mar 2026 19:30:18 +0000 Subject: [PATCH 7/7] tweak CLAUDE.md --- CLAUDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index 2b6da8644e..2a40a8e0d8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,4 +1,4 @@ - never use slice indexing like `arr[n..]` or `arr[i]`; use `.get(n..)`, `.get(i)` etc. instead to avoid panics (clippy::indexing_slicing) - never use `*`, `+`, `-`, `/` for arithmetic; use `.saturating_mul()`, `.saturating_add()`, `.saturating_sub()`, `.saturating_div()` or checked variants instead (clippy::arithmetic_side_effects) - if you are creating a PR to `subtensor` add a `skip-cargo-audit` label -- no `Co-Authored-By` in commits +- no `Co-Authored-By` in commits or attribution in PRs