Skip to main content

Clarent

English | Español

ci PyPI license: Apache-2.0 python: >=3.11

clarent ach scoring the flaky-test example, then listing the next tests to run

Real output of clarent ach on the synthetic flaky-test example; only typing speed and pauses are staged (docs/demo/make_ach_gif.py regenerates it).

Classic decision, optimization and engineering methods — as tools that compute, not prompts that sound smart.

What is Clarent?

People and AI agents tend to anchor on the first plausible hypothesis. Proven methods exist (CIA, army, Toyota, NASA, Soviet TRIZ), but they live in manuals. Clarent turns them into commands that compute (a deterministic engine, no LLM involved), not prompts:

Command Origin What it does
clarent ach Analysis of Competing Hypotheses, CIA (Heuer) Ranks rival causes by how much evidence contradicts them and suggests the next test to run.
clarent redteam Red Teaming, US Army (UFMCS) Attacks a design doc or PR and rejects every attack that is not quoted from the text.
clarent triz-matrix TRIZ contradiction matrix, Altshuller (USSR) Given "improve X without worsening Y", returns the inventive principles from the 1973 table.
clarent spc Statistical Process Control, Shewhart / Western Electric Tells a real shift in CI duration or failure rate from noise and names the candidate commits.
clarent intent Commander's Intent, US Army (ADP 6-0) Delegates with purpose, end state and limits, then checks the change stayed inside them.
clarent rcf Reference Class Forecasting (Kahneman & Tversky; Flyvbjerg) "How long will this take?" from your own PR history, outside view first.
clarent aar After Action Review, US Army (TC 25-20) Reviews a release or incident with computed verdicts and no action without an owner and a check.

The difference: the AI proposes; the engine scores, validates and rejects whatever has no evidence.

Status: v0.2 (beta). Seven methods are implemented end-to-end (ach, 30 tests; redteam, 82; triz-matrix, 38; spc, 15; intent, 16; rcf, 10; aar, 13; core and integrations, 34), and evaluated on real bugs and PRs — see what worked and what did not. Documentation: https://joaquincuevas.github.io/clarent/. Nothing here claims to make your agent fix more bugs — see What we do not claim.

Install

pip install clarent-methods                                        # the `clarent` CLI; Python >= 3.11, no dependencies
# or the development version:  pip install git+https://github.com/Joaquincuevas/clarent
/plugin marketplace add Joaquincuevas/clarent                      # in Claude Code: add the marketplace...
/plugin install clarent-methods@clarent                            # ...and install the skills

Does it help?

Measured on real, already-solved problems, with the failures included (evals/RESULTS.md, reproducible with python evals/run.py). Inputs were written blind by a model from what existed before each fix; one model, one run per case, so these are anecdotes with numbers, not a benchmark.

Method Real cases Result
ach 10 closed bugs (numpy, webpack, axios, jest, pytest, CPython, pydantic) The real cause was among the hypotheses in 10/10 and still alive in 10/10 (7/10 before the v0.2 fixes), but it led in only 5/10; maintainers who knew the code were faster.
redteam 5 merged PRs that later needed a fix The assumption that later failed was named in 3/5 (rank 1 in two); a 1000x slowdown and a PyPy-only bug were missed.
spc pytest's CI, 228 runs One signal, in the window of the first run after a PR that removed quadratic work (15.5 → 13.4 min median). Pure noise alarms in 49% of 50-point series with all four rules.
rcf 400 pytest PRs, backtest Forecasts were optimistic (66% of real durations under P80) and the similarity added nothing over the whole history; it is now optional.
intent a real subagent Blocked once for writing a forbidden path; it deleted the file and passed.
aar the axios 1.15.1 listener leak Verdicts and intervals computed; the first draft was refused for a missing cause.

Integrations

clarent init --dry-run                      # detects the project; then `clarent init` asks before each change
pip install 'clarent-methods[mcp]' && claude mcp add --scope project clarent -- clarent mcp   # every method as an MCP tool
  • MCP server (optional extra): one tool per method for Claude Code, Cursor and other clients — docs.
  • GitHub Action (uses: Joaquincuevas/clarent@v0.2.0): one PR comment with red team findings checked against the code and an SPC chart of CI duration — docs.
  • Claude Code hooks (optional): suggest ach after the same test fails twice, aar when an incident closes, and keep a subagent inside its intent contract — docs.

Why another methods repo?

Military doctrine, Toyota's shop floor, Soviet inventors' algorithms, NASA safety engineering: decades of method for finding root causes, attacking plans and estimating honestly. Clarent turns them into small, auditable tools for developers and their coding agents: Claude Code skills, a CLI, an MCP server, a GitHub Action and optional hooks.

Collections of "thinking frameworks as prompts" already exist (the biggest we found has ~1.7k stars; see research/novelty.md). They give an agent a checklist. Clarent's rule is stricter: every method must have a deterministic core — something the code computes or rejects with no LLM involved — plus evidence discipline:

  • the agent proposes, the engine scores, validates and can say no;
  • every observed fact needs a ref (the command, file:line or log that produced it);
  • reports say what they are: an ACH score is a ranking of inconsistencies, never a probability.

Demo

Everything below is the real output of the command shown, on the synthetic examples shipped in methods/. The files in docs/demo/ hold the complete outputs and are regenerated by python tools/gen_demo.py (CI fails if they drift).

ach — debugging with competing hypotheses

A test, test_checkout_total, fails about 1 run in 8 on CI. Five rival causes and a catch-all, five pieces of evidence, each rated against every hypothesis:

$ clarent ach score methods/ach/examples/flaky-test.json

Excerpt (the full report also has the evidence matrix, diagnosticity, sensitivity and warnings — docs/demo/ach-score.md):

## Conclusion

- Tie: several hypotheses share the lowest inconsistency score.
- Leader(s): H1, H5 (margin over the next: 21)
- This is a ranking of inconsistencies, **not a probability**.

## Hypothesis ranking (lower inconsistency = better)

| # | Hypothesis | Inconsistency | State | Contradicted by |
|---|-----------|---------------:|--------|-----------------|
| 1 | **H1** Race condition between xdist workers on a session-scoped fixture | 0 | alive | — |
| 1 | **H5** Leftover DB state from another test that ran earlier on the same worker | 0 | alive | — |
| 1 | **H6** Something else I am not considering | 0 | catch-all | — |
| 2 | **H2** Clock/timezone dependence (datetime.now near a day boundary) | 21 | refuted | E2, E1 |
| 3 | **H3** Real, unmocked network call that sometimes answers slowly or errors | 27 | refuted | E4, E1 |
| 4 | **H4** Non-deterministic set/dict ordering (PYTHONHASHSEED) changes a float sum | 33 | refuted | E3, E1, E5 |

Clock, network and hash-seed causes are refuted by cited evidence; two causes tie. Which single experiment separates them?

$ clarent ach next methods/ach/examples/flaky-test.json
T1  priority=36.0  for=H5  against=H1
    Reproducing serially with the same random order as the failure (pytest-randomly --randomly-seed=<seed of run #8812>) also fails
T2  priority=9.0  for=H1  against=-
    Changing the fixture from scope=session to scope=function removes the failures in 200 runs with '-n 4'

redteam — attack a design or a PR; the engine refuses what it cannot anchor

A synthetic design doc moves notifications from a cron job to a stream consumer (design.md). A model proposes assumptions and attacks as JSON, each quoting the passage it rests on; the engine checks them against the text:

$ clarent redteam check methods/redteam/examples/design-doc/findings.json

Excerpt (the full report also has the assumption matrix, what to verify next, class coverage and warnings — docs/demo/redteam-check.md):

## Top 3 attacks by impact

| # | Attack | Class | Assumption | Risk | Where | How to check |
|--:|---|---|---|---|---|---|
| 1 | **X3** After the rollout there is no way back: the flag cannot bring back the cron job or the sent_at column, so a bad release can only be fixed by shipping another one while notifications are being lost. | Reversibility | A5 (contradicted) | 25 (S1) | `design.md:26` | Apply the migration in staging, then try to revert to the previous release and send a notification. |
| 2 | **X1** If Redis is down when the API publishes, the row stays in the table but nothing reads it once the cron job is gone: those notifications are never sent and nobody is told. | Failure modes | A1 (contradicted) | 20 (S1) | `design.md:19` | Stop Redis in staging, create 20 notifications, restart Redis and count how many are sent. |
| 3 | **X2** A consumer that crashes after the read and before the provider answers loses the notification: acknowledging on read gives at-most-once delivery, and the row stays pending for ever. | Failure modes | A6 (unverified) | 16 (S2) | `design.md:14` | In staging, kill -9 a consumer between the read and the provider call; count the rows still pending after 10 minutes. |

Where is the line of the design the attack quotes; contradicted means the assumption was checked and the evidence says it is false (here, design.md:15 deletes the only reader of the table), which raises the plausibility of every attack that depends on it. X2 rests on an unverified assumption, so the report lists it first under "Verify next".

The same design with findings the engine must refuse (an invented quote, "verified" with no evidence, a ref to a line that does not exist, a duplicate, an attack with no way to check it) exits 1 and says why:

$ clarent redteam check methods/redteam/examples/design-doc/findings.rejected.json
## Rejected findings

| Kind | ID | Reason |
|---|---|---|
| assumption | A3 | the quote does not appear in the target (compared literally, ignoring only whitespace) |
| assumption | A4 | status 'verified' needs at least one evidence item with a ref and an observation |
| assumption | A5 | evidence ref 'design.md:99' is not valid: line out of range (the file has 27 lines) |
| attack | X3 | its assumption A3 was rejected |
| attack | X4 | the quote has 5 characters; at least 12 are required to anchor a finding |
| attack | X5 | duplicate of X2 (same class and assumption, near-identical text) |
| attack | X6 | no 'check': say how to verify this attack (a command or a concrete question) |
| attack | X7 | its assumption A4 was rejected |
| attack | X8 | its assumption A5 was rejected |

The engine proves a finding is anchored and backed, not that it is right. It also works on PRs (description plus gh pr diff): docs/demo/redteam-pr.md.

triz-matrix — a design trade-off, resolved against the 1973 table

"Make /search faster without making the system harder to run":

$ clarent triz-matrix lookup latency "Device complexity"
# TRIZ contradiction: improve «Speed» without worsening «Device complexity»

- **Improving:** 9. Speed — _software reading: latency, response time or throughput of an operation_
- **Worsening:** 36. Device complexity — _software reading: system complexity: number of components, dependencies, code paths_
- «latency» was interpreted as parameter 9 (Speed) by software-reading match

> Cell verified: the consensus of 4 independent transcriptions equals the Altshuller Foundation 1973 table.

## Principles (in the order the matrix lists them)

| # | Principle | What it means | Software example |
|--:|---|---|---|
| 10 | **Preliminary action** | Carry out the required change, fully or partly, before it is needed. | Precompute results; warm caches; ahead-of-time compilation; pre-pulled images and pre-provisioned environments. |
| 28 | **Mechanics substitution** | Replace the way the parts interact with a different kind of channel or field. | Replace polling with events or webhooks; replace manual review with automated static analysis. |
| 4 | **Asymmetry** | Replace a symmetrical form with an asymmetrical one, or increase existing asymmetry. | Separate read and write paths (CQRS); one writer with many read replicas; asymmetric roles in a protocol. |
| 34 | **Discarding and recovering** | Let parts that have done their job go away or change during operation, and restore used-up parts straight away. | Garbage collection; cache eviction and TTLs; log rotation; automatic cleanup of ephemeral environments; compaction. |

The report goes on with a reminder that principles are prompts for ideas, not solutions, and the reverse cell. triz-matrix analyze methods/triz-matrix/examples/search-api.json does the same for several contradictions at once and ranks the principles that recur (docs/demo/triz-analyze.md). Ambiguous names are rejected with the candidates listed, never guessed.

In Claude Code

/clarent-methods:ach test_checkout_total fails ~1 in 8 CI runs
/clarent-methods:redteam docs/adr-014-event-sourcing.md
/clarent-methods:triz-matrix make /search faster without making it harder to run
/clarent-methods:spc .github/workflows/ci.yml
/clarent-methods:intent migrate the HTTP client to httpx
/clarent-methods:rcf add pagination to /orders
/clarent-methods:aar the 2.4 release

The skills are manual-only (disable-model-invocation), so they cost no context until you call them. ach makes the agent list rival causes first, gather evidence by running commands, rate each item against all hypotheses, and re-score until one explanation survives or the diagnosis is declared unresolved.

Methods

Method Tool Status
Analysis of Competing Hypotheses (Heuer, CIA) ach implemented (reference)
Red Teaming (UFMCS) redteam implemented (beta)
TRIZ contradiction matrix (Altshuller) triz-matrix implemented (beta); additional method, outside the top-10 ranking
Statistical Process Control (Shewhart) on CI spc implemented (beta)
Commander's Intent / Mission Command intent implemented (beta)
Reference Class Forecasting rcf implemented (beta)
Kepner-Tregoe IS / IS-NOT kt spec
Heilmeier Catechism gate spec
Fault Tree Analysis fta spec
HAZOP (guide words on APIs and data flows) hazop spec
After Action Review (US Army TC 25-20) aar implemented (beta)
FMEA, STAMP / STPA fmea, stpa deferred to v2

The ranking is the author's judgment, not a measurement; scores, criteria and the corrections made along the way are in research/ranking.md. 63 methods were catalogued, each source marked read / exists / blocked / unverified: research/.

What we do not claim

  • That a skill makes an agent solve more tasks. Our eval (evals/RESULTS.md) measures what the engines do with model-written inputs on real cases; it does not compare agents with and without Clarent.
  • That the numbers are Heuer's, Shewhart's or Goldratt's. Where a constant is ours (weights, thresholds) the method card says so.
  • That the catalog's sources are all verified. Each one carries its verification level.
  • That the TRIZ matrix data has a clean chain of title. Its licenses and gaps are written down in DATA_LICENSE.md; 29 of its 1 248 cells are contested between transcriptions, and you can supply your own matrix with --data.
  • That the examples are real incidents. Files in methods/*/examples/ are synthetic and labelled so; the real cases are in evals/, each with its source links.
  • That the specified methods exist. kt, gate, fta and hazop are specifications; nothing is promised about when they ship.
  • That the red team's findings are correct. The engine rejects findings that are not quoted from the text or not backed by evidence; whether an attack is right is still a judgment. Three of its six attack classes (scale, dependency, reversibility) are Clarent's own and are not in the UFMCS handbook it draws on.
  • That it works in agents other than Claude Code. The plugin is validated with claude plugin validate and the MCP server is tested with the official MCP client; Cursor, Codex and others have not been tested.
  • That the ranking of methods is a measurement, or that its "no existing repo" findings are proof of absence: they are lower bounds from GitHub search.

Contributors

Contributing

A new method is one folder, one card, one engine, tests and an example. Start with CONTRIBUTING.md; clarent doctor tells you what is missing.

License

Apache-2.0. See LICENSE.

Metadata

Release files for clarent-methods 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clarent-methods 0.2.0
File Size Uploaded Provenance Actions
clarent_methods-0.2.0.tar.gz 803.6 kB With provenance Details for clarent_methods-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clarent-methods 0.2.0
File Interpreter ABI Platform Actions
clarent_methods-0.2.0-py3-none-any.whl Python 3 none any Details for clarent_methods-0.2.0-py3-none-any.whl

Total release size: 1.1 MB

Release files / clarent_methods-0.2.0.tar.gz

Download URL clarent_methods-0.2.0.tar.gz
Size 803.6 kB
Tags Source
SHA-256 checksum
How to use checksums
08cade14a699b4e35eac31b3411d8545ea4625e018b9bd35588bedab2ff0dd6b
BLAKE2b-256 checksum
How to use checksums
34b6a24094d5d9528063ae81c00e8a9f3557d60271a374b8600c6de1c4189373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / clarent_methods-0.2.0-py3-none-any.whl

Download URL clarent_methods-0.2.0-py3-none-any.whl
Size 263.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e31ff02a8de771d556a80f36a29a9b29ef6829f32aabfeaee1333d0fc68b69c
BLAKE2b-256 checksum
How to use checksums
e630194312dfd63c6d5b091d0c68866ba6a71d96072a4c7d18f24b3f2537adf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for clarent-methods 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for clarent_methods-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page