
Mutation Testing
FreeAutomate mutation testing and test generation for Clojure.
Free · Opens the source repo
What Mutation Testing does
The Mutation Testing skill provides a comprehensive solution for running mutation tests on Clojure namespaces. By automating the process, it generates coverage reports, groups functions based on coverage relationships, and utilizes the claude CLI to write necessary tests. The skill ensures that surviving mutations are addressed by creating draft pull requests (PRs) linked to issues in Linear, streamlining the testing and development workflow. This is particularly useful for teams looking to enhance their test coverage and ensure code reliability.
To use the skill, developers need to have a running nREPL connected to the Metabase development environment, along with a valid Linear API key and the gh CLI authenticated with GitHub. The skill can be invoked with a specific Clojure namespace and optional parameters for base branch and project ID, allowing for flexibility in how tests are generated and tracked. The process includes generating a baseline mutation testing report, creating a Linear project for the namespace, and managing the entire lifecycle of test generation and verification.
In addition to the automated test generation, the skill provides mechanisms to handle failures gracefully, allowing users to retry specific groups of functions if needed. This ensures that developers can focus on writing quality code without getting bogged down by the intricacies of mutation testing. The skill's integration with Linear also helps in tracking issues effectively, making it a valuable tool for teams that prioritize continuous integration and deployment practices.
Overall, the Mutation Testing skill is an essential tool for Clojure developers aiming to improve their code quality through robust testing practices. It simplifies the mutation testing process, making it accessible and efficient for teams of all sizes.
When to use it
Use this skill when you want to enhance your Clojure codebase's test coverage and reliability through automated mutation testing.
When not to use it
This skill is not suitable for non-Clojure projects or environments where the required dependencies (like nREPL and Linear) are not set up.
What you can build with it
Enhancing Test Coverage
Use this skill to automatically generate tests for untested code, ensuring better coverage and reliability.
Integrating with Linear
Automatically create Linear issues for mutations that survive testing, streamlining your development workflow.
Managing Code Quality
Regularly run mutation tests as part of your CI/CD pipeline to maintain high code quality and catch potential issues early.
How to install Mutation Testing
View source1. Install with the skills CLI
npx skills add metabase/metabase/mutation-testing --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by metabaseMutation Testing Skill
This skill runs mutation testing end-to-end: generates a coverage report, groups functions, shells out to claude -p to write tests, verifies mutations are killed, and creates draft PRs with Linear issues.
Prerequisites
- A running nREPL connected to the Metabase dev environment
LINEAR_API_KEYenvironment variable set with a valid Linear personal API keyghCLI authenticated with GitHubclaudeCLI available on PATH
Reference Files
dev/src/dev/coverage.clj— mutation testing engine (generates reports, runs mutations)dev/src/dev/mutation_testing.clj— orchestration, Linear API, PR helpers
Invocation
The argument is a Clojure namespace, optionally followed by a base branch:
/mutation-testing metabase.lib.order-by
/mutation-testing metabase.lib.order-by --base-branch release-x.52.x
/mutation-testing metabase.lib.order-by --project-id abc-123
/mutation-testing metabase.lib.order-by --base-branch release-x.52.x --project-id abc-123
--base-branch: defaults to the value in config (set viaset-config!), or"master"if not configured.--project-id: if provided, issues are added to this existing Linear project instead of creating a new one.
Steps
1. Parse arguments
Parse $ARGUMENTS to extract:
- namespace (required) — the first positional argument
--base-branch(optional) — if present, the next argument is the base branch name--project-id(optional) — if present, the next argument is an existing Linear project ID
2. Load and configure
(require '[dev.mutation-testing :as mut-test] :reload)
(require '[dev.coverage :as cov] :reload)
If this is the first invocation (or the REPL was restarted), set up the Linear team:
(mut-test/list-teams!)
(mut-test/set-config! {:team-id "<id>"})
3. Run
(mut-test/run! '<target-ns>)
;; Or with options:
(mut-test/run! '<target-ns> {:base-branch "release-x.52.x"})
(mut-test/run! '<target-ns> {:project-id "abc-123"})
(mut-test/run! '<target-ns> {:base-branch "release-x.52.x" :project-id "abc-123"})
Pass the opts map with :base-branch and/or :project-id if those flags were provided in the arguments.
This will:
- Generate a baseline mutation testing report
- Create a Linear project for the namespace
- Group functions by coverage relationships
- For each group: create branch → invoke Claude to write tests → verify → retry if needed → commit & push → create Linear issue → create draft PR
- Print a summary with PR links
4. Handle failures
If a group fails mid-processing, run! catches the error and continues to the next group. To retry a single group manually:
;; Get the parsed namespace info
(def parsed (mut-test/parse-namespace '<target-ns>))
;; Run coverage to get the data
(def coverage-results (cov/test-namespace (:target-ns parsed) [(:test-ns parsed)]))
;; Group and find the one you want
(def groups (mut-test/group-functions coverage-results))
;; Process just that group
(mut-test/process-group! parsed (nth groups <index>))
5. Verify the prompt (dry run)
To inspect what Claude will see without invoking it:
(def parsed (mut-test/parse-namespace '<target-ns>))
(def coverage-results (cov/test-namespace (:target-ns parsed) [(:test-ns parsed)]))
(def groups (mut-test/group-functions coverage-results))
(println (mut-test/build-test-prompt
(merge (select-keys parsed [:target-ns :test-ns :source-path :test-path])
(select-keys (first groups) [:fn-names :mutations]))))
Configuration
- Team ID: Set once per REPL session via
(mut-test/list-teams!)and(mut-test/set-config! {:team-id "..."}) - Project ID: Set automatically when
run!callscreate-project-for-namespace! - Base Branch: Defaults to
"master". Override via(mut-test/set-config! {:base-branch "release-x.52.x"})or pass{:base-branch "..."}as the second arg torun! - Project ID: If set (via
set-config!orrun!opts),run!reuses the existing Linear project instead of creating a new one
Frequently asked questions about Mutation Testing
Similar skills
Rhino 3D Scripting
Streamline your Rhinoceros 3D scripting tasks.
MVVM Toolkit
Streamline ViewModel development with source generators.
FreeCAD Scripts
Generate Python scripts for FreeCAD automation and modeling.
Azure Architecture Builder
Design and deploy Azure infrastructure using natural language.
Command Development
Streamline your command creation for Claude Code.
Create Cowork Plugin
Easily build and package plugins through guided sessions.
