test-and-fix

test-and-fix is a command for Claude Code from solanabr/solana-ai-kit. It costs 7 tokens per session (2,087 once invoked), scanned A, original, MIT.

A command that runs the project's tests, investigates failures, applies common fixes, and runs the tests again. It supports Rust projects, including Anchor and Solana programs.

In plain words
What is it for?
Use it to check a Rust codebase after changes and address formatting problems, code-quality warnings, and other common test failures.
Why use it?
It removes the repetitive work of switching between test output, diagnosis, small corrections, and another test run. It stops when tests pass or when a person needs to intervene.

Command for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it to check a Rust codebase after changes and address formatting problems, code-quality warnings, and other common test failures.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/solanabr/solana-ai-kit/test-and-fix
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/solanabr/solana-ai-kit

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-and-fix

README.md
[![agentmods](https://agentmods.dev/badge/commands/solanabr/solana-ai-kit/test-and-fix.svg)](https://agentmods.dev/commands/solanabr/solana-ai-kit/test-and-fix)
Your own site
<a href="https://agentmods.dev/commands/solanabr/solana-ai-kit/test-and-fix"><img src="https://agentmods.dev/badge/commands/solanabr/solana-ai-kit/test-and-fix.svg" alt="Measured on agentmods" height="20"></a>
Per session 7 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,087 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00007 $0.02087
Opus 5 $0.00003 $0.01043
Sonnet 5 $0.00001 $0.00417
Haiku 4.5 $0.00001 $0.00209

Measured 8d ago against content hash 9894c58e358f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

test-and-fix scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

2 near-identical copies found in the catalogue:

.claude/commands/test-and-fix.md · 372 lines

How it starts

The opening of the file, as written. The whole thing — 372 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are running tests and fixing any issues found. This command iteratively tests, diagnoses problems, fixes them, and retests.

Overview

This command follows a test → diagnose → fix → retest loop until all tests pass or manual intervention is needed.

Step 1: Initial Test Run

echo "🧪 Running initial tests..."

# Determine project type and run appropriate tests
if [ -f "Anchor.toml" ]; then
    # Anchor project
    anchor build && anchor test --skip-deploy
    TEST_STATUS=$?
elif grep -q "solana-program" Cargo.toml 2>/dev/null; then
    # Native Solana program
    cargo build-sbf && cargo test
    TEST_STATUS=$?
else
    # Standard Rust or backend
    cargo test
    TEST_STATUS=$?
fi

if [ $TEST_STATUS -eq 0 ]; then
    echo "✅ All tests passed!"
    exit 0
fi

echo "❌ Tests failed. Starting diagnosis..."

Step 2: Diagnose Issues

Analyze the test output to categorize failures:

Common Issue Categories

  1. Format Issues

    • Code not formatted
    • Inconsistent style
  2. Clippy Warnings

    • Lints not satisfied
    • Potential bugs
  3. Compilation Errors

    • Syntax errors
    • Type mismatches
    • Missing imports
  4. Test Failures

    • Failed assertions
    • Logic errors
    • Account validation failures (Solana)
  5. Runtime Errors

    • Panics
    • Arithmetic overflow
    • Account errors (Solana)

Step 3: Automatic Fixes

Fix Format Issues

# Always start with formatting
echo "📝 Fixing format issues..."
cargo fmt

# For TypeScript tests
if [ -d "tests" ] && ls tests/*.ts >/dev/null 2>&1; then
    npx prettier --write "tests/**/*.ts"
fi

echo "✅ Format fixed"

Fix Clippy Warnings (Auto-fixable)

echo "🔧 Fixing clippy warnings..."

# Apply automatic clippy fixes
cargo clippy --fix --allow-dirty --allow-staged

# Note: Not all clippy warnings are auto-fixable
# Manual fixes may be needed for:
# - Logic issues
# - Unsafe code
# - Complex refactorings

echo "✅ Clippy auto-fixes applied"

Read the full file on GitHub · 372 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 372 lines · 7 tokens per session scan A 9894c58e358f

Subscribe to this mod's changes

test-and-fix is a command published in the GitHub repository solanabr/solana-ai-kit (101 stars, last pushed 18d ago), licensed MIT. It adds 7 tokens to every session and 2,087 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.