Aptitude
A test harness for validating AI agent (Claude Code) behavior against steering guides. This tool executes Claude with prompts and asserts on the tool calls made.
Installation
From crates.io
From Homebrew
From source
Usage
The harness has two main commands:
Run tests
Execute Claude with a test file and evaluate assertions:
# Run a single test
# Run all tests in a directory
# With verbose output and custom working directory
Analyze existing sessions
Analyze a pre-existing Claude session log against test assertions:
Test File Format
Tests are defined in YAML files:
name: "Test name"
prompt: "The prompt to send to Claude"
assertions:
- tool: Read
called: true
params:
file_path: "*.txt" # glob pattern
- tool: Bash
called: false
- tool: Write
called_after: Read
Assertion Types
called: true/false- Whether a tool was calledparams- Parameter matching (supports glob patterns, regex, or exact match)called_after- Ordering assertions (tool A must be called after tool B)
Development
# Build the project
# Run tests
# Run a specific test
Release Process
This project has fully automated releases to both crates.io and Homebrew:
One-time setup
-
Create crates.io API token:
- Go to https://crates.io/settings/tokens and create a token
- Add it as
CARGO_REGISTRY_TOKENsecret in GitHub repo settings
-
Create GitHub personal access token:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Create a token with
repopermissions for your homebrew-tap repo - Add it as
HOMEBREW_TAP_TOKENsecret in GitHub repo settings
-
Create Homebrew tap repository:
Create a new release
# Bump version and trigger fully automated release
This single command automatically:
- Updates version in
Cargo.tomlandCargo.lock - Creates and pushes a git tag
- Triggers GitHub Actions that:
- Builds binaries for all platforms
- Creates GitHub release with binaries
- Publishes to crates.io
- Calculates SHA256 hashes for Homebrew formula
- Updates and pushes the Homebrew formula to your tap
No manual steps required!
Architecture
- parser.rs - Parses Claude Code JSONL session logs
- assertions.rs - Test structure and assertion evaluation
- executor.rs - Executes Claude and finds session logs
- watcher.rs - File watching for incremental parsing
License
MIT