v2.5.34 GitHub
matcha

matcha Documentation

Engineering philosophy for AI coding agents. Think before you code — purpose, reuse, stack, review.

🚀 Quick Start 📦 Installation

Introduction

matcha is an engineering philosophy for AI coding agents. It makes agents think before they code — checking purpose, reusing existing code, auditing the stack, and reviewing before shipping.

The Problem: AI agents write code fast, but often write the wrong code. They skip planning, duplicate existing logic, ignore security, and ship without review. The result: more bugs, more tech debt, more rework.
The Solution: matcha adds a lightweight enforcement layer that forces agents to follow engineering best practices — without slowing them down for simple tasks.

How It Works

matcha operates at 4 layers:

LayerWhat It DoesWhen It Runs
Planning GateBlocks code until Intent Discovery plan existsBefore any implementation
Safety ShieldBlocks dangerous commands (rm -rf, git push --force)On every command
Post-Write ScanChecks files for cleanup issues (13+ languages)After every file write
Review Gate9-category review with risk-based routingBefore shipping

Who Is It For?

Solo Developers

Use AI agents but want guardrails to prevent bad code from shipping.

Teams

Enforce consistent engineering standards across all AI-assisted code.

Security-Conscious

Automated security checks before code reaches production.

Legacy Codebases

Incremental refactoring with safety protocols for large projects.

Key Features

Purpose-First Thinking

Intent Discovery (problem, goals, success criteria, What → Why → How) forces agents to understand WHY before writing code. No more blind implementation.

Deterministic Enforcement

Hook-based safety checks run in Node.js, not LLM. Zero dependency on AI for critical checks.

Risk-Based Review

4-tier review routing (L0-L3). Quick tasks skip, critical code gets expert-level scrutiny.

Universal Compatibility

Works with Claude, Cursor, Copilot, OpenCode, Windsurf, Kiro, and any MCP client.

Adaptive Modes

Auto-detects what the agent is doing. Explore, implement, refactor, debug — zero friction.

13+ Languages

Pattern registry for JS, TS, Go, Python, Rust, Java, C#, C/C++, Ruby, Swift, PHP, Kotlin, Dart.

What's Inside

ComponentCountDescription
Modules6Core, project, modes, risk, engineering, legacy
Commands7why, review, audit, intensity, status, debt, markers
Agents6planner, finder, auditor, reviewer, cleaner, debugger
Hooks4shield, post-write, stop, metrics
MCP Tools4shield_check, post_write_scan, stop_tips, plan_validate
Languages13+JS, TS, Go, Python, Rust, Java, C#, C/C++, Ruby, Swift, PHP, Kotlin, Dart
Trigger Packs6web-saas, ml-pipeline, infra-iac, mobile, embedded, cli-tool

Example: Before vs After matcha

Without matchaWith matcha
Agent writes code immediatelyAgent plans first (Intent Discovery)
Duplicates existing functionsSearches codebase, reuses existing
Ships without review9-category review gate
No security checksAutomated security scanning
Same process for all tasksAdaptive modes (explore/implement/debug)
Breaks legacy codeIncremental batching with safety

Quick Start

Up and running in 2 minutes.

1

Install matcha

One command. Works on macOS, Linux, and WSL.

npx @plumpslabs/matcha@latest init

Or install globally:

npm install -g @plumpslabs/matcha && matcha init

Or without npm (curl script):

curl -fsSL https://raw.githubusercontent.com/plumpslabs/matcha/main/install.sh | bash
2

Configure your provider

Matcha auto-detects your platform (Claude Code, OpenCode, Cursor, Windsurf, Kiro, and more) and installs the right files. No manual configuration needed.

3

Add project constraints (optional)

Copy the template and fill in your project-specific rules:

cp .agents/skills/matcha/modules/project.md ./MATCHA_PROJECT.md
# Edit with your framework, package manager, coding standards
4

Verify installation

Check that the rules files are installed:

ls AGENTS.md GEMINI.md hooks/matcha-shield.js
# All three must exist — matcha is now active for every agent.
Done! Your agent now follows matcha's philosophy. Rules are active in every tool; safety hooks are installed in hooks/ and wired into .claude/settings.json for Claude Code.

Installation

Multiple ways to install matcha depending on your setup.

Option A: npx — one command, nothing installed globally

npx @plumpslabs/matcha@latest init

npx downloads matcha temporarily, runs init into the current project, then discards it. No global install, no cleanup. Re-run any time to update.

During init, matcha asks which providers to configure (1 Claude · 2 OpenCode · 3 Cursor · 4 Windsurf · 5 Kiro · 6 Universal). Existing providers are auto-detected. For scripting: matcha init --platforms .opencode,.claude

Option B: Global install — matcha command works everywhere

npm install -g @plumpslabs/matcha
matcha init        # install matcha rules into the current project
matcha status      # verify + show platform detection

The matcha CLI is available in every project. Run matcha init in each project you want to enable.

Option C: Project-local dev dependency — pinned per repo

npm install --save-dev @plumpslabs/matcha
npx matcha init

Scoped to one project via package.json. Best for teams — the matcha version is locked with the code.

Option D: One-liner — no npm required

curl -fsSL https://raw.githubusercontent.com/plumpslabs/matcha/main/install.sh | bash

Pure shell script, works on macOS / Linux / WSL. Installs the rules files only (no CLI).

Which one should I use?

SituationCommandWhy
Most users — try it outnpx @plumpslabs/matcha@latest initOne command, zero cleanup
Use matcha in many projectsnpm install -g @plumpslabs/matchamatcha CLI available everywhere
Team repo, pinned versionnpm install --save-dev @plumpslabs/matchaVersion locked in package.json
No Node.js / no npmcurl one-linerPure shell, no dependencies

What Gets Installed

TargetContentsFor
AGENTS.md + CLAUDE.md + GEMINI.md + QWEN.mdRoot context files (per-runtime: Claude Code, Antigravity/Gemini, Qwen Code, + universal AGENTS.md)Every agent (Claude, Antigravity, Qwen, Gemini, Codex, Zed, ...)
.github/copilot-instructions.mdCustom instructionsGitHub Copilot
.claude/6 agents, 7 commands, skill + modules, hooks + settings.jsonClaude Code
.opencode/6 agents, 7 commands, skill + modulesOpenCode
.cursor/rules/matcha.mdc ruleCursor
.windsurf/matcha.md rule + .windsurfrulesWindsurf
.clinerules/matcha.md ruleCline
.roo/rules/matcha.md ruleRoo Code
.kiro/3 steering files, skill + modulesKiro Code
.qoder/rules/matcha.md ruleQoder
.trae/rules/matcha.md ruleTrae IDE
.agents/6 agents, 7 commands, skill + modules + rules/Universal / Antigravity (AGY)
agents/ + rules/ + mcp_config.jsonAGY plugin package structure (per official plugin layout)Antigravity — agy plugin install
hooks/Planning-gate, shield, post-write, stop, metrics, agy-hooks, instructions, MCP serverEvery agent (server-side safety)
Safety: matcha uses safe-merge for settings. It will NOT overwrite existing hooks from other tools (Kuma, Fennec, etc.).

Claude Code Setup

matcha works natively with Claude Code via plugin marketplace or manual setup.

Method 1: Plugin Marketplace

# Inside Claude Code
/install matcha

Method 2: npm install

1

Install matcha

npx @plumpslabs/matcha@latest init

Method 3: Curl script

1

Run install script

curl -fsSL https://raw.githubusercontent.com/plumpslabs/matcha/main/install.sh | bash
2

Hooks are auto-configured

The install script creates .claude/settings.json with hooks (merged, not overwritten).

3

Verify

ls AGENTS.md .claude/skills/matcha/SKILL.md
# Should show both files — Claude Code is configured ✅

MCP Configuration (Optional)

Add matcha MCP tools for additional enforcement:

{
  "mcpServers": {
    "matcha": {
      "command": "node",
      "args": ["hooks/matcha-mcp-server.js"]
    }
  }
}

Place in .mcp.json (per-project) or ~/.claude.json (global).

OpenCode Setup

matcha auto-detects OpenCode and configures agents + skills.

1

Install matcha

npx @plumpslabs/matcha@latest init
2

Auto-detected

OpenCode reads .opencode/agents/*.md and .opencode/skills/matcha/SKILL.md automatically.

MCP Configuration

OpenCode's mcp schema requires command to be an array (executable + args together).

Per-project

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "matcha": {
      "type": "local",
      "command": ["node", "hooks/matcha-mcp-server.js"],
      "enabled": true
    }
  }
}

Place in opencode.json / opencode.jsonc in the project root.

Global (all projects) — no absolute path needed

npm install -g @plumpslabs/matcha
# Then in ~/.config/opencode/opencode.json:
{
  "mcp": {
    "matcha": {
      "type": "local",
      "command": ["matcha", "mcp"],
      "enabled": true
    }
  }
}

matcha mcp resolves via your global PATH — works from any project, nothing to update when you switch directories. (Fallback: absolute path ["node", "/path/to/matcha/hooks/matcha-mcp-server.js"] if the CLI isn't installed globally.)

Don't: "command": "node", "args": [...] — OpenCode rejects this with Expected "array". Property args is not allowed. Put everything inside command.

Cursor Setup

matcha works with Cursor via AGENTS.md (native) and optional MCP.

1

Install matcha

npx @plumpslabs/matcha@latest init
2

AGENTS.md auto-detected

Cursor reads AGENTS.md in project root automatically.

MCP Configuration (Optional)

{
  "mcpServers": {
    "matcha": {
      "command": "node",
      "args": ["hooks/matcha-mcp-server.js"]
    }
  }
}

Place in .cursor/mcp.json (per-project) or ~/.cursor/mcp.json (global).

Windsurf Setup

matcha works with Windsurf via .windsurfrules.

1

Install matcha

npx @plumpslabs/matcha@latest init
2

.windsurfrules auto-generated

Windsurf reads .windsurfrules in project root automatically.

MCP Configuration

{
  "mcpServers": {
    "matcha": {
      "command": "node",
      "args": ["hooks/matcha-mcp-server.js"]
    }
  }
}

Place in ~/.codeium/windsurf/mcp_config.json (global only).

agy (Antigravity) Setup

matcha works with agy (Antigravity CLI) via plugin install.

Method 1: Plugin Install

agy plugin install https://github.com/plumpslabs/matcha

Method 2: npm install

1

Install matcha

npx @plumpslabs/matcha@latest init

Method 3: Curl script

1

Run install script

curl -fsSL https://raw.githubusercontent.com/plumpslabs/matcha/main/install.sh | bash
2

Auto-detected

agy reads GEMINI.md and .agents/ automatically.

What Gets Installed

The repo ships an AGY-compatible plugin manifest (plugin.json) plus root agents/ and mcp_config.json so agy plugin install picks up everything:

Using matcha agents

AGY discovers the 6 matcha agents from .agents/agents/ (project) and the plugin's agents/ dir. Verify with:

agy agent          # list discovered agents (4 primary shown)
agy --agent matcha-planner "plan feature X"   # one-shot, no TUI
ActionHow
Pick an agent inside the TUIType /agents → arrow to the agent → EnterEsc
Start a session with an agentagy --agent <name> <prompt> (per-session only — AGY has no persistent default-agent setting)
List agentsagy agent
Shift+Tab ≠ agents. In AGY, Shift+Tab only cycles built-in execution modes (plan, auto-edit). Custom agents are selected via the /agents panel or --agent flag — this is normal AGY behavior, not a bug. debugger and cleaner are subagent-only (mainAgent: false) so they don't appear in agy agent; they run via invoke_subagent from a main agent.
Note: AGY converts plugin commands into skills. The /matcha slash command is the core skill; command skills are invoked via matcha:review-style names. Hooks use Claude Code's format, so they are not registered by AGY's plugin scanner.

Kiro Setup

matcha works with Kiro via steering files in .kiro/steering/.

1

Install matcha

npx @plumpslabs/matcha@latest init
2

Steering files created

.kiro/steering/matcha.md, dev-mode.md, review-mode.md

MCP Server Setup

matcha exposes 4 tools via MCP (Model Context Protocol) for any compatible client.

Available Tools

ToolDescription
matcha_shield_checkCheck a command for dangerous patterns
matcha_post_write_scanScan a file for cleanup issues (13+ languages)
matcha_stop_tipsGet end-of-task suggestions from git diff
matcha_plan_validateValidate an Intent Discovery plan

What Is This For?

MCP (Model Context Protocol) lets any AI agent call matcha's checks as tools — deterministic enforcement that doesn't depend on the agent reading rules. It's optional: the rules files (AGENTS.md, skills, commands) work without it. MCP adds a second, programmatic layer for agents that support tool calls (Claude, Cursor, Windsurf, AGY, OpenCode, ...).

Start the Server

Locally (project hooks dir):

node hooks/matcha-mcp-server.js
# Runs via stdio JSON-RPC

Or via the globally installed CLI (works from any project):

npm install -g @plumpslabs/matcha
matcha mcp

Client Configuration

Each client has a different config format:

ClientConfig fileFormat
Claude Code.mcp.json (project) / ~/.claude.json (global)"mcpServers": { "matcha": { "command": "matcha", "args": ["mcp"] } }
OpenCodeopencode.json (project) / ~/.config/opencode/opencode.json (global)"mcp": { "matcha": { "type": "local", "command": ["matcha", "mcp"], "enabled": true } }
Cursor.cursor/mcp.json (project) / ~/.cursor/mcp.json (global)"mcpServers": { "matcha": { "command": "matcha", "args": ["mcp"] } }
Windsurf~/.codeium/windsurf/mcp_config.json (global only)"mcpServers": { "matcha": { "command": "matcha", "args": ["mcp"] } }
AGY / Antigravitymcp_config.json (auto via plugin) or ~/.gemini/config/mcp_config.json"mcpServers": { "matcha": { "command": "matcha", "args": ["mcp"] } }
Cline / Roo~/.cline/mcp.json / .roo/mcp.json"mcpServers": { "matcha": { "command": "matcha", "args": ["mcp"] } }

Global config tip: use "command": "matcha", "args": ["mcp"] (global CLI) — no absolute path, works after switching projects. Absolute path to hooks/matcha-mcp-server.js is only needed if the CLI isn't installed globally.

Global vs Per-Project: We recommend per-project MCP config (.mcp.json) — safer, easier to remove, can be committed to repo. Use the global CLI form if you want it everywhere.

Philosophy

Simple. Efficient. Deliberate. Never twice.

The 6-Checkpoint Filter

Every implementation passes through 6 checkpoints:

#CheckpointPurpose
1Purpose + ReuseIntent Discovery + search for existing code
2Stack AuditCheck for service overlap
3ImplementationWrite code with principles
4CleanupRemove temp files, debug code
5VerifyRun tests, typecheck, lint
6Review GateRisk-based review (L0-L3)

Core Principles

Context-Aware Modes

matcha auto-detects what the agent is doing and adjusts behavior.

ModeTriggerPlanning GateReview Gate
ExploreReading, grepingSkipSkip
ImplementWriting new codeEnforceEnforce
RefactorChanging existing codeEnforce + legacyEnforce
DebugError, investigatingSkipSkip
ReviewFinished implementingSkipIs the review

Modes are detected automatically from tool input. No manual switching needed.

Risk-Based Review

Not all code needs the same review. Route by risk.

Risk Tiers

TierRiskReview Level
L0DisposableOutput check only
L1LowLint + typecheck
L2Product LogicFull 9-category review
L3High RiskExpert review + threat model

Trigger Packs

matcha does NOT hardcode what "high risk" means. Detection uses domain-specific trigger packs:

web-saas

Auth, payments, secrets, DB schema

ml-pipeline

Data leakage, PII, model deploy

infra-iac

Destructive applies, IAM, prod paths

mobile

Keychain, permissions, IAP

embedded

Memory, interrupts, watchdog

cli-tool

rm -rf, sudo, eval

See hooks/matcha-trigger-packs.json for all packs and custom template.

L2 Full Review Categories

SeverityCategoryChecks
🔴 Must FixCorrectnessLogic, edge cases, race conditions, dead code
🔴 Must FixPerformanceO(n²+), N+1, unbatched I/O, unbounded operations, re-render loops, memory leaks
🔴 Must FixSecurityInjection, secrets, authN/authZ + IDOR, fail-closed
🟡 Should FixArchitectureGod objects, circular deps, over-engineering
🟡 Should FixErrors, Logging & ValidationEmpty catches, generic messages, secrets/PII in logs, missing boundary validation
🟡 Should FixResilience & DataTimeouts, retry + backoff, circuit breaker, transactions, migrations with rollback
🟡 Should FixQualityDuplication, magic numbers, deep nesting
🟢 Nice to HaveTestingCoverage, edge cases
🟢 Nice to HaveMaintainabilityWHY comments, env vars

Planning Gate

Blocks code modifications until an Intent Discovery plan exists.

Smart Auto-Skip

Planning gate is automatically skipped for:

Plan Format

<matcha_gate>
  <what>Describe what you are building/fixing — with file refs</what>
  <why>Why is this necessary? — with evidence</why>
  <how>Simplest implementation path — numbered steps</how>
</matcha_gate>

Validation Rules

Proportionality & Trivial Fast-Pass

Match ceremony to risk. The gates exist to protect — not to slow you down. Over-analysis is not rigor; it is waste.

Task SizeDefinitionGate Required
Trivial≤5 LOC, 1 file, no logic change (typo, rename, copy, config value, docs)Fast-pass — no full gate
Small1–3 files, contained changeShort plan + lint review
LargeCross-cutting / production risk (auth, payments, DB, schema)Full gate + risk-based review

Trivial Plan Marker

For trivial tasks, write a minimal plan carrying the <!-- trivial --> marker (or type: plan-trivial in frontmatter) plus a **Problem:** line — the hook accepts it without the full What/Why/How gate. Without the marker, the hook still requires Problem + Goals + Success Criteria.

<!-- trivial -->
# 🍵 Intent Discovery
- **Problem:** Rename `foo` to `bar` in src/x.js

What Skips the Gate Automatically (Smart Auto-Skip)

Exit Conditions Beat STOP

Before stopping to ask the user, ask: is this actually blocking, or can I proceed on a recorded assumption? Prefer proceeding with a visible assumption over blocking on trivia. Record assumptions in the plan's Assumptions field so they survive context compaction.

Project Constraints

matcha supports project-specific rules that agents must follow.

Setup

cp .agents/skills/matcha/modules/project.md ./MATCHA_PROJECT.md

Template Sections

Auto-loading: matcha automatically loads MATCHA_PROJECT.md from project root when present.

Session Memory

Filesystem is durable memory; the context window is volatile. matcha persists gate artifacts so a compacted or fresh session resumes in under 500 tokens.

FileWriteRead
.agents/plan/current.mdPlanning gate → overwrite (living plan)Start of every task
.agents/reports/<agent>-<YYYY-MM>.mdReview / Audit output → appendResuming or auditing history
.agents/plan/decisions.logmatcha decision <type> <reason>matcha markers / /matcha:debt

Rules

Lifecycle (anti-stale)

current.md always holds exactly one active task:

  1. Start — read it. Intent matches the current request? Continue and update in place. Mismatch → overwrite (never follow a stale plan).
  2. During (step-by-step) — implement strictly in order from the Plan list: after each completed step check it off ([x]) and update the **▶ Current:** line (Step N/M, K done). Overwrite / check-off in place, never append. The plan always reflects the real position — a compacted or fresh session resumes exactly where you left off. Deviation → update the plan first.
  3. Done (task ships = review PASS) — the reviewer finalizes the handoff: append plan content to reports/planner-<YYYY-MM>.md, write the verdict to reports/reviewer-<YYYY-MM>.md, then reset current.md to the empty template (status: active, TBD). Only a PASS resets — BLOCK / PASS_WITH_FIXES keeps the plan for fix iteration.

Portable across providers.agents/plan/ + .agents/reports/ are plain files in the project, readable by any provider (OpenCode, AGY, Claude, Cursor, …). Switch provider mid-task? The new session injects AGENTS.md → reads current.md → resumes. The filesystem is the memory; the provider is just the host.

Workflow Guide (The 4-Phase Lifecycle)

How to actually use matcha day-to-day: which agent or command to call, when, and in what order — from a blank task to a reviewed, shippable change.

The 4-Phase Lifecycle: Every feature or bugfix flows through 4 distinct phases (Plan → Search → Code → Ship) to eliminate technical debt before it reaches production.

End-to-End Flow Diagram

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│  Phase 1: PLAN  │ →  │ Phase 2: SEARCH │ →  │ Phase 3: CODE   │ →  │  Phase 4: SHIP  │
│  @matcha-planner│    │  @matcha-finder │    │  Main agent     │    │ /matcha:review  │
│  (/matcha:why)  │    │  (Reuse Check)  │    │ (verify + debug)│    │ @matcha-cleaner │
└─────────────────┘    └─────────────────┘    └─────────────────┘    └─────────────────┘

Implementasi dilakukan oleh main agent (bukan sub-agent) — mengikuti plan di .agents/plan/current.md step-by-step. @matcha-debugger hanya dipanggil jika terjadi error, dan @matcha-finder bisa dipanggil ulang saat menemukan kode yang bisa di-reuse.

1

Phase 1: Plan & Intent

/matcha:why or @matcha-planner. In enforce mode the planning gate runs automatically — the agent must state What / Why / How with empirical evidence before touching any file. No blind implementation.

2

Phase 2: Search & Reuse

@matcha-finder: "Check if there's existing code for X." Search codebase for exact or partial matches (`file:line`). Mandate reuse over rewrite — never duplicate what already exists.

3

Phase 3: Implement & Verify

Implement directly according to the plan in .agents/plan/current.md — check off steps ([x]) and update the **▶ Current:** line as you go. Follow the Engineering Directives (Type-Safe, Boundary Guard, Pure Core, Security, Resource & Memory Awareness). Verify runs automatically after each change (tests + typecheck + lint). If an error occurs, invoke @matcha-debugger for systematic 1-hypothesis-at-a-time investigation with log evidence — debugger is for failures, not the default implementer.

4

Phase 4: Review & Ship (Blocking Gate)

/matcha:review & @matcha-cleaner. Run full risk-based review (L0-L3). Nothing ships without PASS. Run @matcha-cleaner to remove debug logs and mark intentional shortcuts with // matcha: [reason] — deliberate-choice comments (skip/workaround/intentional hardcode) get the marker at write time, not as a separate cleanup pass.

5

Verify (automatic)

Tests + typecheck + lint run automatically (framework auto-detected). Red tests → stop and fix, never continue.

6

Review gate — before "done"

/matcha:review or @matcha-reviewer. Risk-based routing: L0 output check → L1 lint/typecheck → L2 full review (9 categories) → L3 expert + threat model. Verdict: BLOCK / PASS_WITH_FIXES / PASS / EXPERT_REQUIRED. If blocked, use @matcha-debugger to find the root cause.

7

Cleanup & debt

@matcha-cleaner removes temp/debug/unused code. /matcha:debt and /matcha:markers surface decision markers (// matcha: ...) and open items.

8

Report

/matcha:status shows the session dashboard: components, intensity, changes, test results.

When to Call What

PhaseAutomatic?CommandAgentExample
SetupNo/matcha:intensitySet enforce / observe / audit
PlanGate auto-runs/matcha:why@matcha-planner"Plan this feature with Intent Discovery"
ReuseNo@matcha-finder"Is there existing code for X?"
AuditOptional/matcha:audit@matcha-auditorHealth check before legacy refactor
ImplementRules enforced"matcha pause" if a better path appears
VerifyYesTests + typecheck + lint
ReviewNo — must run/matcha:review@matcha-reviewerGate before "done"
Debug (if blocked)No@matcha-debugger"Find the root cause of the N+1 query"
CleanupNo/matcha:debt /matcha:markers@matcha-cleanerRemove temp/debug/unused
ReportNo/matcha:statusSession dashboard

Mode by Situation

ModeWhenBehavior
observeExploring, prototyping, learning a new codebaseTips only — no blocking
enforceNormal implementation work (default)Planning gate + shield active
auditCritical paths: auth, payments, DB, legacy refactors, pre-releaseEnforce + mandatory cleanup
Rule of thumb: default to enforce. Drop to observe when exploring. Raise to audit when the stakes are high. Always end with /matcha:review.

Commands Reference

7 slash commands for matcha workflows.

CommandPurposeUsage
/matcha:whyIntent Discovery checkBefore any implementation
/matcha:reviewRisk-based review gateAfter implementation
/matcha:auditStack auditCheck for overlaps
/matcha:intensitySet enforcement level/matcha observe|enforce|audit
/matcha:statusSession dashboardCheck current state
/matcha:debtTechnical debt reportFind // matcha: markers
/matcha:markersMarker scanGroup by severity

Note: /matcha:status now surfaces session metrics (planning-gate blocks, shield blocks, reviews run, issues caught, FP rate) when .agents/matcha-metrics.json exists — so matcha can measure its own overhead.

CLI Reference

Run matcha <command> after installing via npm (or node bin/matcha.js <command> from the repo). All commands resolve state at the workspace root (monorepo-aware).

CommandPurpose
matcha initInteractive provider picker → runs install.sh for the selected platforms
matcha statusInstallation health: detected platforms, AGENTS.md, shield, intensity + metrics snapshot
matcha metricsImpact & overhead telemetry: tasks, reviews, issues caught, FP rate, planning/shield blocks (from .agents/matcha-metrics.json)
matcha markersScan // matcha: decision markers grouped by severity
matcha verifyCheck installed rule copies across providers (anti-stale)
matcha stateInspect session state (intensity, plan, metrics paths)
matcha decisionLog a technical decision to .agents/plan/decisions.log
matcha mcpLaunch the matcha MCP server (stdio)
matcha -v / --versionPrint version only
matcha helpShow usage

Agents Reference

6 specialized agents for matcha workflows.

Read-only agents (planner/finder/reviewer/auditor) have provider-enforced edit: deny (OpenCode) / disallowedTools: Write, Edit (Claude Code) — they can never modify source code. Only plan/report paths are writable. debugger/cleaner may modify code.

AgentRead ToolsEdit (write) AccessBashPurpose
@matcha-plannerRead, Grep, Glob, List.agents/plan/current.md + .agents/reports/** onlyDeniedEngineering planning: Intent Discovery → context → reuse → decision → roadmap
@matcha-finderRead, Grep, Glob, ListDeniedDeniedHunt existing code before writing new
@matcha-auditorRead, Grep, Glob, List.agents/reports/** onlyAllowedStack audit for overlaps and risks
@matcha-reviewerRead, Grep, Glob, List.agents/reports/** onlyAllowedCode review with risk-based routing (runs lint/tests)
@matcha-cleanerRead, Grep, Glob, ListAllowed (after confirmation)AllowedRemove temp/debug/unused code
@matcha-debuggerRead, Grep, Glob, ListAllowed (minimal fix)AllowedSystematic debugging workflow

Provider note: enforced in OpenCode (permission:) and Claude Code (disallowedTools:). Other providers (agy, Cursor, Windsurf) read the same agents as prompts — enforcement there is prompt-level + safety hooks.

Hooks Reference

4 lifecycle hooks for deterministic enforcement.

HookEventPurpose
matcha-shield.jsPreToolUseBlocks dangerous commands + mode detection
matcha-post-write.jsPostToolUseScans files for cleanup issues (13+ languages)
matcha-stop.jsStopEnd-of-task suggestions from git diff
matcha-metrics.jsSharedSession metrics tracking

Override

MATCHA_SHIELD_OFF=true  # Disable all shield checks

Modules Reference

6 focused modules loaded on-demand.

ModuleWhen to LoadContent
core.mdAlways6-checkpoint filter, intensity, planning gate
project.mdAlwaysProject-specific constraints (MATCHA_PROJECT.md template)
modes.mdAlwaysContext-aware mode switching
risk.mdDuring reviewRisk-based review routing (L0-L3)
engineering.mdImplement + reviewUniversal engineering bar: errors, logging, validation, API contracts, state, concurrency
legacy.mdLegacy codebasesIncremental batching, impact analysis

Benchmark & Evidence

Matcha ships its own benchmark tooling (benchmark/) and publishes results — so the claim "rules improve output without bloating it" is measured, not asserted.

What matcha is: engineering guardrails for AI coding agents — planning before code (Intent Discovery), reuse-first, security & quality review gates, verification before claiming done. It turns "fast but sloppy" agent output into "deliberate and verified" output.
Where it earns its cost: multi-file refactors, cross-layer bug hunting, security/auth/production-critical changes, and teams that need standards enforced rather than suggested.
Where it's overkill: trivial single-file edits (typo, rename, one-line feature) — Proportionality routes those through the ≤30-line fast path; drop to /matcha:intensity observe (tips only, no blocking) while exploring or prototyping.
🏆 The headline: no-rules agents fail a multi-file refactor (0/2 — they add a few lines and stop). Matcha is the only arm that completes it — service layer extracted, no regression in existing behavior. The price: more tokens and wall time on small tasks — the cost of the planning and verification other arms skip. That trade is measured in the small-task section below, not hidden.

Complex-Task Benchmarks (v3) — where a thinking-first agent earns its cost

First run (free model, n=1–2/cell, 2026-08-08): the arena matcha was built for — and the arms split hard.

Task❌ No rules💬 Terse🍵 Matcha
refactor-users-service — completed0/2 ❌ (+3 LOC, refactor not done)0/2 ❌ (+3 LOC, refactor not done)✅ 1/1 (+15 LOC, service layer extracted, tests green)
refactor-users-service — defect densityn/a (no-op)n/a (no-op)6.7 (1 finding / 15 LOC)
fix-auth-security — passed✅ 1/1 (+8 LOC)✅ 2/2 (+4 LOC)✅ 1/1 (+16 LOC, density 0)

Honest reading: without rules the agent fails the multi-file refactor — it adds a few lines and stops; matcha is the only arm that extracts the service layer without breaking behavior. The table shows completed cells: matcha's second refactor cell and several security cells hit the free-model queue timeout (the same security task passed at 240s in an isolated dry-run), so its 1/1 is not cherry-picking. On the small security bug every arm that finished fixed it — no measurable edge for matcha there. Defect density only counts completed work: a 3-line no-op has no density to measure.

Quality metric: defect density — anti-pattern findings (empty catches, magic numbers, hardcoded secrets) per 100 LOC added by the agent, scanned via hooks/patterns.json. This is the value side of the ledger: baseline writes few, sloppy lines; matcha writes more, cleaner lines. Re-run: node benchmark/live-bench.js --task refactor-users-service --arm matcha --n 5 --timeout 480.

Small-Task Benchmarks (18 runs) — the cost of thinking first

Real feature implementation on the express-api fixture (3 features × 3 arms × 2 iterations). This is matcha's worst case: trivial single-file tasks. Process cost (tokens, steps, wall time) is measured from real provider events, not estimated. Lower is better for every chart except Correctness.

Median per arm · data as of 2026-08-07 (re-run: node benchmark/live-bench.js --all --n 5, then update docs/benchmark.json + this chart) · details in docs/BENCHMARK.md. Cost is the invoice for the quality shown above — not a defect.

Metric (median)❌ No rules💬 Terse🍵 MatchaVerdict
Correctness (fail→pass)1.01.01.0Tie — rules don't hurt or help on small tasks
ExpectedPass (target suite)5/65/65/6Tie — sharper metric, still no correctness edge
LOC added13.56.517Matcha writes more — structure over brevity (anti-overbuild fix cut +136% → +26%)
Tokens (real)395K347K643KMatcha +63% — the price of planning + verification (see below; variance high — BENCHMARK.md)
Wall time58s34s78sMatcha +34% — same invoice on trivial tasks (was +70% pre-fix)
Compliance (changed files)100100100Tie — all arms clean

Why matcha costs more — the mechanism: the extra tokens and time are mostly process steps, not code bloat. Matcha adds ~4 LLM turns per task (steps 8.5 → 12.5), which typically go to the planning gate (write a plan with evidence before touching files), verification (run the test suite), and the review pass. Each extra turn re-reads context — that's the ~49K cacheRead/step we measured. On small tasks those turns buy nothing visible — hence "overkill by design". On complex tasks they are exactly what turns a 0/2 failure into a completed, verified refactor.

Honest takeaway: cost (tokens/time) is context, not the verdict. Matcha spends more because it thinks before it implements — that buys precision, structure, and prevention. The quality side is why the cost is worth paying: defect density (anti-pattern findings per 100 LOC added, scanned on agent-written files only), correctness, and safe complex refactors. On small/trivial tasks matcha is overkill by design — Proportionality routes them through the ≤30-line fast path and the trivial plan; use /matcha:intensity observe for trivia.

So is matcha "slow and expensive"? Read the cost table as an invoice for verification, not a waste report: the same kind of process turns — planning and verification — that cost +63% on trivial tasks are the ones that completed a refactor every other arm abandoned. And the premium is capped by design — trivial edits skip the gate entirely (≤30-line fast path) and observe mode removes it altogether. You only pay the premium where you choose to — and it buys what no-rules arms never produce: a completed, verified result on the work that actually matters.

The cost you're not seeing — the rework loop. The token table compares upfront cost only. It ignores what happens after: in the complex-task run, no-rules arms didn't produce worse code — they produced unfinished code (a +3 LOC no-op, refactor never done). Unfinished code isn't cheaper; it's a redo ticket.
Assumption (estimated, not measured): one redo — detect the bug, reopen the session, re-understand the code, re-implement, re-test — costs ≈1.5× the original run, mostly because re-understanding re-reads the codebase all over again (the same standing-context cost we measured at ~49K/step). On the small-task numbers that's ≈590K tokens per redo — larger than matcha's entire +248K premium. One redo and no-matcha has already spent more tokens than matcha's whole run (≈985K vs 643K) — plus the developer hours in between, which tokens don't capture. Two redos, and it ships with debt on top. Matcha's premium is paid once, up front; the no-matcha cost is paid later, repeatedly, with interest.

Real Multi-Turn Feature Benchmark (agy, 3 features)

FeatureLOCTestsPassedCompliance
Activity Tracking11112✅ 12A
Pagination6710✅ 10A
Rate Limiting758✅ 8A
Total27030✅ 30/30Excellent

Matcha-driven feature builds on agy (Gemini 3.5 Flash): 3 real features, all tests green, top compliance grade. The same-prompt with/without comparison lives in docs/BENCHMARK.md — matcha produced named status codes, explicit errors, and a per-user data structure at ~16% more LOC.

Legacy / internal runs. Agentic A/B (Claude Code, 20 tasks × 3 arms): all arms tied at 13/20 correct — matcha wrote 260 LOC vs 347 no-rules via reuse/no-duplication, but this benchmark doesn't differentiate. Standing-context A/B (20 cells, core-only vs full): −6.3% tokens median, within run-to-run noise — the slim is correct-by-architecture (~1.5K tok/step) but standing context is dominated by AGENTS.md + hooks + system prompt, not skill modules. Full write-ups in docs/BENCHMARK.md.

Which feature to use when

FeatureUse it when…
@matcha-planner / plan gateStarting any non-trivial feature — Intent Discovery (What → Why → How) before any code
@matcha-finderBefore writing new code — hunt existing helpers first; never duplicate what exists
@matcha-auditor / /matcha:auditStack overlap, dependency risk, security & PII exposure — read-only, report-only
@matcha-reviewer / /matcha:reviewBefore commit — L0–L3 risk-tiered review, catches what the agent missed
/matcha:intensityScale enforcement per task: enforce (default) / observe (exploring) / audit (high stakes)

Rough rule: bigger than a one-file edit, or production-critical → matcha earns its keep. Everything else → fast path + observe keeps it out of the way.

Run It Yourself

Every published number is re-runnable — the harness ships in benchmark/:

node benchmark/live-bench.js --all --n 5        # full A/B: 6 tasks × 3 arms (headless opencode, tokens+time)
node benchmark/live-bench.js --task refactor-users-service --arm matcha --n 5 --timeout 480   # complex-task run
node benchmark/matcha-bench.js ./src            # compliance scan of your code
node benchmark/agentic-runner.js --simulate     # deterministic smoke test, no Claude needed

Complex tasks run 200s+ per cell on free models — pass --timeout 480 for refactor/security tasks. Full methodology in docs/BENCHMARK.md.

Architecture

Layered by design. Each layer does one thing.

1 AGENTS.md Primary cross-tool rules
2 Skills + Modules 5 load-on-demand modules
3 Project Constraints MATCHA_PROJECT.md
4 Hooks Shield, post-write, stop, metrics
5 MCP Server 4 tools, cross-platform
6 Commands + Agents 7 commands, 6 agents