Skip to main content

A CLI + TUI testing framework for Claude Code harness components

Project description

Harness Test

Python 3.12+ Typer Pydantic v2 Rich Claude Agent SDK uv

Test your Claude Code harness the same way you test code — run a command, get a report, know what works.


About

Harness Test is a CLI testing framework for Claude Code harness components — CLAUDE.md, skills, hooks, subagents, and AGENTS.md.

It provides three testing layers with increasing depth and cost:

Layer What it does Token cost
Static validation Syntax, structure, broken references, rule conflicts Zero
Behavioral testing Runs prompts against Agent SDK, evaluates assertions Per-test
Statistical evaluation Multi-run consistency and variance analysis Multi-run

Tech Stack

Category Technology
Language Python 3.12+
CLI Typer
Data Models Pydantic v2
Terminal Output Rich (tables, Live streaming)
YAML Parsing ruamel.yaml (round-trip fidelity)
Test Executor Claude Agent SDK
Package Manager uv
Linter / Formatter Ruff
Type Checker Pyright
Tests pytest + pytest-asyncio

Architecture

┌─────────────────────────────────────────────────────┐
│                     CLI (Typer)                      │
│              init  ·  run  ·  report                 │
├──────────┬──────────┬──────────────┬────────────────┤
│ Scanner  │Validator │   Runner     │   Reporter     │
│          │          │              │                │
│ claude_md│ claude_md│  executor    │  formatter     │
│ skills   │ skills   │  (Agent SDK) │  (Rich tables) │
│ hooks    │ hooks    │  assertions  │                │
│ subagents│ subagents│  collector   │                │
│ agents_md│references│              │                │
│ memory   │ rules    │              │                │
├──────────┴──────────┴──────────────┴────────────────┤
│                 Pydantic Models                      │
│   component · config · test_spec · results · valid. │
└─────────────────────────────────────────────────────┘

Data Flow:

init:     scan_project() → detect_auth() → write_config()
static:   load_config() → scan_project() → validate_all() → Rich table
behavior: load_config() → load_all_specs() → run_tests() → save_results() → Rich Live
report:   load_results() → scan_project() → render_report() → Rich tables / JSON

Project Structure

src/harness_test/
  cli.py            # All CLI commands (init, run, report)
  config.py         # Auth detection + config management
  spec_loader.py    # YAML test spec loader
  main.py           # Typer app entry point
  models/           # Pydantic models (component, config, test_spec, results, validation)
  scanner/          # One scanner per harness type + scan_project() orchestrator
  validator/        # One validator per concern + validate_all() orchestrator
  runner/           # Agent SDK executor, assertions, result collector, run_tests()
  reporter/         # Rich formatter + render_report()
tests/              # Mirrors src/ structure
.harness-test/      # Runtime config (config.yaml, test results)

Getting Started

Prerequisites

  • Python 3.12+
  • uv package manager
  • Claude Code subscription (for behavioral tests) or Anthropic API key

Installation

git clone https://github.com/hgflima/harness-test.git
cd harness-test
uv sync

Usage

1. Initialize

Discover harness components, detect auth method, and create config:

uv run harness-test init

2. Run Tests

# Static validation (zero tokens)
uv run harness-test run --layer static

# Behavioral tests via Agent SDK
uv run harness-test run

# Re-run only failed tests
uv run harness-test run --failed

3. View Report

# Rich terminal output
uv run harness-test report

# JSON for CI pipelines
uv run harness-test report --json

Development

uv run pytest                     # Run test suite (218 tests)
uv run ruff check src/ tests/     # Lint
uv run ruff format src/ tests/    # Format

Key Design Decisions

  • Pydantic everywhere — All data crosses module boundaries as Pydantic models, never raw dicts
  • Scanner/Validator symmetry — Each harness component type has a matched scanner + validator pair
  • ruamel.yaml over PyYAML — Round-trip fidelity for YAML specs
  • Executor isolation — Each behavioral test runs in its own Agent SDK session
  • Exit codes0 success, 1 failures/errors, 2 runtime/config errors

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Run tests and linting (uv run pytest && uv run ruff check src/ tests/)
  4. Commit your changes
  5. Open a Pull Request

Acknowledgements


If this project helps you test your Claude Code harness, consider giving it a star.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harness_test-0.1.0.tar.gz (9.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

harness_test-0.1.0-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

Details for the file harness_test-0.1.0.tar.gz.

File metadata

  • Download URL: harness_test-0.1.0.tar.gz
  • Upload date:
  • Size: 9.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for harness_test-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f2727bebd6328ba215c6c3d7b2c644d360c56aea0084c0d38eb458e279549cb2
MD5 96d86149370c5b9d836737cd9b59aa5d
BLAKE2b-256 43d3e76c3e6f30c449134e69b796cff71bd8d2b0ebf3b79be8a194628fa7b919

See more details on using hashes here.

File details

Details for the file harness_test-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: harness_test-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for harness_test-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ea5c4240b0ddd155b01bcd7b5b21b3e624bed59b83ceacb4bb0370375fa27e8
MD5 8fe1ae5f5385200ad45ae1207c72ec39
BLAKE2b-256 59e0890181120f83d87975eb2c42cd1b9faa649da72b3c22f417fe2abb437353

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page