agentleFS
garthcodesgarthcodes/claude-skills/skills/test-changed/SKILL.md

test-changed

Skill2 starsChanged 2 months agoMITView on GitHub

Orchestrate parallel test generation for all changed components, jobs, models, policies, and services in the current branch. Native replacement for scripts/test-changed-all.sh.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If --every-file is set, only guards 1 and 2 apply.

    line 37
  2. Distinctive:

    Run discovery for all five categories.

    line 41
  3. Very specific:

    If --include-specs is set, also pick up changed files under spec/<dir>/.

    line 68
  4. Very specific:

    If --dry-run, stop here.

    line 90
  5. Distinctive:

    If every category is empty, print a green "Nothing to do — no changed files in any category." and exit.

    line 92
  6. Very specific:

    All non-empty category agents are dispatched in a single assistant turn with multiple Agent tool calls so they run concurrently — the same …

    line 147

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Test Changed — Parallel Test Coverage Orchestrator

Native Claude orchestrator that mirrors scripts/test-changed-all.sh. Discovers files changed in the current branch across five categories, then dispatches one specialized test-generation agent per category in parallel to create or improve specs for each changed file.

CategorySource dirSpec dirSkill to invoke
componentsapp/components/spec/components/viewcomponent-test-expert
jobsapp/jobs/spec/jobs/rspec-test-expert
modelsapp/models/spec/models/rspec-test-expert
policiesapp/policies/spec/policies/rspec-test-expert
servicesapp/services/spec/services/service-test

Inputs

Parse $ARGUMENTS for these flags (any order; pass-through behavior matches the original script):

  • --dry-run — Discover files and print what would be processed, then stop. No agents are dispatched.
  • --every-file — Process every file in each source dir, not just files changed on the branch.
  • --include-specs — Also pass any changed spec files to the relevant agent for review/improvement (not just new/missing specs).
  • -h / --help — Print the table above plus this options list, then stop.
  • Any non-flag positional argument is treated as the base branch (default main).

Hard-Stop Guards

Before discovery, verify:

  1. The working directory is inside a git repo (git rev-parse --is-inside-work-tree).
  2. git branch --show-current returns a non-empty branch name.
  3. The base branch exists locally (git rev-parse --verify <base>). If not, suggest git fetch origin <base> and abort.
  4. The merge base (git merge-base <base> HEAD) resolves. If not, abort with a clear message.

If --every-file is set, only guards 1 and 2 apply.

Step 1 — Discover Files

Run discovery for all five categories. Use Bash to compute the diff once, then filter in-process. Pseudocode (adapt to actual paths):

BASE="${BASE_BRANCH:-main}"
MERGE_BASE=$(git merge-base "$BASE" HEAD)

if [ "$EVERY_FILE" = true ]; then
  CANDIDATES=$(find app/components app/jobs app/models app/policies app/services -name "*.rb" -type f | sort)
else
  CANDIDATES=$(git diff --name-only --diff-filter=AMR "$MERGE_BASE" HEAD)
fi

Then bucket each candidate path into a category and skip these excluded files (they have no business spec):

  • app/components/application_component.rb
  • app/jobs/application_job.rb
  • app/models/application_record.rb, app/models/concerns/** (concerns are tested via includers — skip them unless --include-specs is set and a concern spec already exists)
  • app/policies/application_policy.rb
  • app/services/application_service.rb, app/services/base_service.rb, app/services/concerns/**

For each kept source file, derive:

  • Class name — snake_case path under app/<dir>/ → CamelCase with :: separators. Example: app/services/billing/charge_service.rb → Billing::ChargeService.
  • Spec path — swap app/ for spec/ and append _spec.rb. Example: app/services/billing/charge_service.rb → spec/services/billing/charge_service_spec.rb.
  • Spec status — [spec exists] or [no spec] (used to choose the agent's prompt).

If --include-specs is set, also pick up changed files under spec/<dir>/. Map each spec back to its source path and add it to its category's list (deduped).

Step 2 — Print Discovery Summary

Print a compact summary BEFORE dispatching agents, grouped by category:

Discovered changes vs <base> (merge-base <short-sha>):

  components (2)
    UserAvatarComponent (app/components/user_avatar_component.rb) [spec exists]
    Billing::InvoiceRowComponent (app/components/billing/invoice_row_component.rb) [no spec]
  jobs (0)
  models (1)
    Client (app/models/client.rb) [spec exists]
  policies (0)
  services (3)
    ...

Dispatching 3 agents (skipping empty categories: jobs, policies).

If --dry-run, stop here.

If every category is empty, print a green "Nothing to do — no changed files in any category." and exit.

Step 3 — Dispatch Agents in Parallel

For each non-empty category, dispatch one Agent in parallel (single message, multiple Agent tool uses). Use subagent_type: "general-purpose". Each agent's prompt must be self-contained and include:

  1. The category name and the list of (class_name, source_path, spec_path, spec_status) tuples to process.
  2. The skill the agent should invoke per file (from the table at the top).
  3. A loop instruction: for each tuple, invoke the appropriate skill with a prompt tailored to whether the spec exists.
  4. The expected report format (see Step 4).

Prompt template (per agent)

You are processing the <category> category for the test-changed orchestrator. Process the files below sequentially. For each file, invoke /<skill-name> via the Skill tool with the prompt indicated.

Files to process:

  1. <ClassName> — source: <source_path>, spec: <spec_path>, status: <spec_status>
  2. ...

If status is [no spec] invoke the skill with:

Create comprehensive RSpec tests for the <ClassName> <singular-category>.

  • Source file: <source_path>
  • Spec file to create: <spec_path>

Read the source, generate the spec following project conventions (FactoryBot, Result objects where applicable, multi-tenant context, etc.), then run bundle exec rspec <spec_path> and iterate until green.

If status is [spec exists] invoke the skill with:

Review and improve the RSpec tests for the <ClassName> <singular-category>.

  • Source file: <source_path>
  • Spec file: <spec_path>

Read both files, identify gaps in coverage (public methods, success/failure paths, edge cases, side effects), add the missing tests, then run bundle exec rspec <spec_path> and iterate until green.

After each file, record one of: PASS, FAIL <one-line reason>, or SKIP <reason>.

When done, return a single message with this exact shape:

CATEGORY: <category>
RESULTS:
  <ClassName> — PASS | FAIL: <reason> | SKIP: <reason>
  ...
SUMMARY: <N pass> / <N fail> / <N skip>

Do not commit, push, or create PRs.

<singular-category> is component, job, model, policy, or service.

Parallelism rule

All non-empty category agents are dispatched in a single assistant turn with multiple Agent tool calls so they run concurrently — the same shape as the original bash & + wait pattern.

Step 4 — Aggregate and Report

Once all agents return, print a combined summary (mirrors the bash script's COMBINED SUMMARY block):

========================================
COMBINED SUMMARY
========================================

  PASS  components (2/2)
  FAIL  services   (2 pass, 1 fail)
  ...

----- Failures -----
  services / Billing::ChargeService — spec failed after 3 iterations: ActiveRecord::RecordInvalid on factory(:invoice)

Next steps:
  1. Review changes: git diff
  2. Re-run any failed category: bundle exec rspec <failed_spec_paths>
  3. Commit when satisfied

Exit non-zero (in spirit — i.e. surface clearly to the user) if any category reported failures, matching the script's exit-1 behavior.

Principles

  1. One message dispatches all categories. This is the entire point of "parallel" — do NOT serialize the Agent calls.
  2. Mirror the bash script's file-selection rules exactly. Same excludes, same --diff-filter=AMR, same merge-base comparison, same class-name derivation.
  3. Don't shell out to the original scripts. This skill is the native replacement; calling scripts/test-changed-all.sh would defeat the purpose.
  4. Don't commit anything. The user reviews git diff and commits themselves — same as the original script.
  5. Empty categories are skipped silently in agent dispatch but listed in the discovery summary so the user can see they were considered.
  6. --include-specs is additive, not a mode switch — it adds spec-file-driven entries to whatever the changed-source pass produced.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.