Skip to main content
Glama

CRAB

Clean Rebuild of Anything's Behavior

Clean-room reimplementation by black-box observation.

See a feature you like. Rebuild it from how it behaves, never from its code.

Python 3.12+ MCP servers Targets PyPI Apache-2.0 license

Quick start · How CRAB works · What you can analyze · Results · FAQ · Documentation

uv tool install "crab-cleanroom[web]" && crab demo

NOTE

CRAB was calledTeardown until 0.3. The teardown command, TEARDOWN_* variables and an existing ~/.teardown keep working for this release; the package is now crab-cleanroom.

IMPORTANT

CRAB is early software (0.4). You declare the purpose of every analysis at intake and own its legal assessment. ReadResponsible use first.


See a feature in an app that you want in your own product? CRAB lets you rebuild it without ever looking at its implementation. One agent, the observer, studies the app as a black box. It records what the app accepts, refuses and defaults to, what it does at the edges, and how its screens are sequenced. CRAB turns that into falsifiable rules and claims and releases them as a sanitized spec. A second agent, the clean implementer, sees only that spec and writes its own implementation. It can check its work against the original, but it only ever gets back abstract pass/fail verdicts.

The valuable knowledge about a feature is behavioral. Tracing the implementation through binaries, minified bundles or obfuscated code is slow, brittle, and copies expression you don't want. CRAB never captures code, decompilation or stack traces. What it cannot observe becomes an explicit unknown, not a silent gap.

Both sides can run enforced, not just instructed. The observer works in a container whose only way to the target is CRAB's drivers. The implementer works in a container that sees only the spec. Every crossing goes through the gate and is recorded in a signed, hash-chained audit log.

Quick start

Install

uv tool install "crab-cleanroom[web]"   # Python 3.12+; the command is `crab`
crab install-browser                   # Chromium for web targets
crab demo                              # observe -> gate -> clean -> verdict on a built-in example

pip install "crab-cleanroom[web]" works too, and uv tool install "crab-cleanroom[web] @ git+https://github.com/lemonadesaltbagel/crab" installs the latest unreleased version. Docker is needed for CLI targets (each run is isolated in a container) and for the enforced rooms; an installed copy builds the room images from files it carries. Android needs the SDK and an emulator or device reachable through adb.

To work on CRAB itself, use a checkout: git clone https://github.com/lemonadesaltbagel/crab.git, then uv sync and uv run crab ....

Set up your agent

Register the observe server with your agent (Claude Code shown; any MCP client works):

claude mcp add crab-observe -- crab observe --project /path/to/project

From a checkout, use uv run --directory /path/to/crab crab observe ... instead.

Then ask:

Open web:http://localhost:3000/ as a research target and follow the observe_target playbook:
discover the UI, probe every field, inject API faults, state rules, close the coverage gaps
and release the spec.

The playbook (docs/observer-playbook.md) is served as the observe_target MCP prompt; the observer guide (docs/observer-guide.md) details every tool.

Review and release

crab review  --project P --feature F           # gate findings by class, coverage gaps
crab approve --project P --feature F --by you@example.com --class expected-output --reason test-oracle
crab release --project P --feature F
crab export-clean --project P --out KIT        # the kit: released spec + build/verify scaffolding

In strict mode every release needs your approval at a terminal, and the observer's tools cannot approve anything. In practice that is a few class-level decisions per release: approve the app text the clone must reproduce, approve the action names, acknowledge the coverage gaps the observer explained (docs/strict-gate.md).

Rebuild in the clean room

crab cleanroom up    --project P --kit KIT --claude-token-file ~/.config/crab-claude-token
crab cleanroom check --project P               # isolation probes, run from inside the container
crab cleanroom shell --project P -- claude     # the implementer sees only /kit; `verify` asks the gate
crab cleanroom down  --project P

crab observerroom confines the observer the same way (docs/clean-runtime.md).

Related MCP server: Jukeyman Unleashed

How CRAB works

  1. Observe. Drivers run the target and capture behavior only: outputs and file effects for CLIs, accessibility trees and API exchanges for web apps, accessibility trees for Android. A mapper turns each observation into a compact, wording-agnostic symbol. For web apps that symbol is versioned (web.aria/v10) and records everything a user-facing Playwright test can tell apart.

  2. Generalize. UI discovery crawls every screen. The observer probes fields by equivalence class and boundary, injects faults (server errors, network failures, malformed bodies, unreadable files, airplane mode) and states rules in its own words. CRAB checks every rule against the original and records it as corroborated or falsified. Coverage lists what is left: each control, field, endpoint × fault, data state and live output, every route signed in and signed out, and record pages in each status. A release is refused until every item is exercised or explained.

  3. Gate. The release is checked for copied expression (verbatim and near-verbatim matches against everything observed and every ingested document) and for real names, which become a codename. In strict mode, findings need your recorded approval.

  4. Rebuild. The clean agent builds from the spec and asks the gate to verify its build. The gate runs the original and the clone through the same tests and returns pass/fail with abstract symbols, never the original's text or evidence.

What you can analyze

Target

What CRAB observes

Faults it can inject

Requirements

Status

Command-line tools

Exit code, stdout, diagnostic presence and errno class, file effects

Closed/full stdio, unreadable files, read-only directories

Docker (isolated runner) or local

Stable

Web apps

Everything a user-facing Playwright locator or assertion can tell apart (the accessibility tree with roles, names, levels, states and nesting; field values and properties; titles, focus, status messages, landmarks text), plus API method/path/status and public-contract selectors

5xx, network failure, timeout, malformed body, pending requests, changed responses (server modes); API setup calls to reach deep screens

Playwright Chromium; optional backend reset command

Working: 96.9–99.2% of hidden tests on the last three held-out apps (see Results)

Android apps

Controls by role and name with state flags, visible text, system dialogs

Network off (airplane mode)

Android SDK, emulator or device via adb

Working

Linux desktop apps

AT-SPI tree: windows, controls, text, list items

—

Docker (Xvfb + AT-SPI container)

Experimental

macOS, Windows, iOS

—

—

—

Not started

CRAB refuses to bypass protections and never captures implementation-tier data (see Responsible use).

Results

Each result was scored on a hidden test suite the observer never saw, against the original's own score under the same harness. How the evaluation works, and every result with its caveat, is in docs/evaluation.md.

target

hidden suite

A command-line tool no model has seen

397/397 from the spec alone

Web apps no model has seen (the last three held-out apps)

129/130, 126/130, 125/127

Android apps no model has seen

113/118 and 100/119 (the second built without any verification feedback)

RealWorld "Conduit" web frontend (tooling tuned against it)

99/101

Flipt v1.61.0, a real open-source web app, on its own suite

19/55 in the fourth round (from 9 in the first): an application many times larger; 21 of its tests need a server mode the observer could not find, and the other misses are sections the coverage report listed as unexplored (see the evaluation notes)

  • The clones reproduced their specs. What the hidden suites caught were things the spec did not contain.

  • The web abstraction is built from a principle. It records every difference a user-facing Playwright locator or assertion can see, checked by an audit of page pairs that must differ and pairs that must not.

  • The strict-gate rounds took a few class-level decisions at the person's own terminal per release. The audit log records each one.

  • Famous targets measure the model's memory too. On jq, the same model with no spec at all did as well as with it. That is why the benchmarks use apps written for the purpose.

FAQ

Any agent that supports MCP. The observe server runs over stdio or HTTP (crab observe --port). The enforced rooms ship a container with Claude Code and register only the room's CRAB server. Any other agent that can run in the container and use a proxy works too.

No. Drivers capture behavior-tier data only. Stack traces are redacted at capture, Android resource ids and activity names never enter observations, and web API bodies are reduced to value-free shapes. In the observer room, the observer agent cannot reach the target's files, bundles or the internet at all: only CRAB's tools.

The implementer's container mounts only the kit. Its only network peer is an egress proxy that allows the gate and the model API. The gate accepts only clones built from the kit and returns abstract verdicts. Unexpected errors come back generic, so dirty-side detail cannot leak through them. cleanroom check proves the isolation from inside the container.

No container can close that gap. If the implementer's model already knows the target, part of the result is memory. CRAB asks implementers whether they recognized the target and reports it. The uncontaminated benchmarks use apps written for the purpose.

CRAB runs locally. Your agents send their tool results to their model provider, which has its own data policy.

That depends on your jurisdiction, the target's terms and what you build. CRAB records your declared purpose and shows applicable warnings, but it does not give legal advice. A clean room addresses copying of expression. It does not address patents, trademarks or trade dress.

Documentation

  • Observer playbook: the loop the observer agent follows (also an MCP prompt).

  • Observer guide: driving the dirty side for CLI, web and Android targets.

  • Strict gate: reviewing findings and approving releases.

  • Clean runtime: the enforced clean room and observer room.

  • Evaluation: the benchmark method and every result with its caveats.

Responsible use

CRAB never:

  • bypasses CAPTCHAs, bot protection, certificate pinning, root or attestation checks, or FLAG_SECURE;

  • flips Electron fuses or re-signs binaries;

  • uses fake accounts or exceeds configured rate limits;

  • captures implementation-tier data (code bodies, decompilation, stack traces).

These refusals are not configurable. Observe only software you are allowed to observe, within its terms. You declare your purpose at intake and own the legal assessment.

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md for the ground rules, and report anything that could let information cross the clean-room barrier privately through SECURITY.md. Changes are listed in CHANGELOG.md.

uv sync
uv run ruff check src tests
uv run pytest -q    # Android and desktop tests run when an emulator / the desktop image is available

License

Apache License 2.0. See NOTICE.

The license covers CRAB's own code and documents. CRAB grants no rights in the software you analyze: observing a target, and building and distributing anything from what you observed, remain subject to that target's terms and the law that applies to you.

Available Tools

31 tools
add_quoteC

Standard mode only: allow one literal through the gate, with the reason it is functionally necessary.

Inputs: text (required), approved_by (required), compat_reason (required). Returns: object

answer_ticketC

Answer a clean-side question; the answer is gate-checked.

Inputs: answer (required), ticket_id (required). Returns: object

api_contractB

Web: the value-free backend contract observed so far (paths, methods, statuses, body shapes). Fold data-bearing path segments with target_options.api_templates.

Inputs: no named parameters. Returns: object

approve_observed_outputB

Standard mode only: approve byte-exact output the behavior requires (default: help/usage/version output) as functional quotes. Records who approved it.

Inputs: feature (required), approved_by (required), action_ids. Returns: object

audit_verifyB

Verify the audit log's hash chain.

Inputs: no named parameters. Returns: object

blocked_hostsB

Web: third-party hosts the app tried to load during one episode (reset + actions); candidates for target_options.profile.asset_hosts when layout depends on them.

Inputs: actions. Returns: result

check_rulesC

Check observer-authored rules against the original. Each rule: {statement (your own words), origin: documented|inferred-intent|observed, kind, checks: [{kind: outcome|same|differs, a: invocation, b: invocation (same/differs), expect: subset (outcome), keys: [..] (optional)}]}. Falsified documented rules are reported as documentation/behavior conflicts.

Inputs: rules (required), feature (required). Returns: object

compile_specC

Compile a spec draft (model + claims + unknowns) for a feature.

Inputs: feature (required). Returns: object

coverageC

Coverage of a feature inventory {item: [patterns]} by probes and rule checks (options are added automatically). Uncovered items become unknowns.

Inputs: feature (required), inventory. Returns: object

define_actionsB

Define named actions (CLI invocations: argv, stdin, files, env, stdin_mode, stdout_mode, timeout_s) for learning flows of stateful CLIs.

Inputs: actions (required). Returns: object

discover_cliB

Discover a CLI's interface: help structure confirmed by behavior probes. Help prose is kept as dirty-side evidence only; the result is structure (options, arity, value types).

Inputs: cmd (required), takes_files. Returns: object

discover_uiA

UI targets: crawl from the start screen (or after the named start actions, e.g. a sign-in) clicking every enabled control; screens are identified by route, headings and controls. Defines a click[role:name] action for every control found and records the inventory that coverage and suggest_probes use. Start here, then probe fields and state rules.

Inputs: feature (required), fill, start, max_depth, +1 more. Returns: object

falsify_claimC

Try to falsify a claim with fresh, uncached probes.

Inputs: claim_id (required), repeats. Returns: object

ingest_docsB

Register public documentation you read (dirty side). Its paragraphs join the gate corpus so copied wording is flagged; write rules in your own words.

Inputs: text (required), source (required). Returns: object

learn_flowC

Learn a state machine for a feature with KV or L# under an explicit oracle budget.

Inputs: feature (required), alphabet (required), walk_len, algorithm, +1 more. Returns: object

list_claimsC

List claims, optionally for one feature.

Inputs: feature. Returns: result

list_feature_unknownsB

List unknowns (yours and the ones coverage generated) with id, question and status, so they can be answered with update_unknown.

Inputs: feature. Returns: result

list_rulesB

List the rules recorded for a feature: id, statement, status, failed checks.

Inputs: feature (required). Returns: result

list_ticketsC

List questions from the clean side.

Inputs: no named parameters. Returns: result

open_targetB

Open a target and record intake (declared purpose, jurisdiction, ToS snapshot). target: cli:docker: | cli:build: | cli:local | web: | android:: | desktop:docker:. strict: every release needs a person's approval at a terminal. target_options (web): reset_command, reset_check_url, contract_selectors {source, selectors}, api_templates, profile {asset_hosts, ...}; see the observer guide.

Inputs: target (required), purpose (required), strict, account, +6 more. Returns: object

probe_cliC

Probe a CLI feature: one-factor sweep, pairwise over accepted classes, noise calibration (rerun + env variations), probe table, mined decision-table claims and unknowns. hints = {cmd, base, selector_options, takes_files, default_input, sweep_inputs, inputs, pair_inputs, operand_type, unicode_argv, skip_options, extra_inputs, extra_values}.

Inputs: hints (required), feature (required), pairwise, env_sample. Returns: object

probe_web_fieldB

Probe one form field (web, Android or desktop UI): equivalence classes for its kind (text/email/password/number or custom classes), a length-boundary search, per-class outcomes and folded claims. prefix = named actions that reach the form; submit = the named action that submits it. Boundary classes become named actions you can add to learn_flow's alphabet. When accepted values change the outcome (computed results), say what acceptance looks like: accepted_if = {subset: {...}} and/or {text_contains: '...'}. Number fields skip the length search (their limits are ranges). Without submit, the outcome is read right after typing (live previews, totals, counters).

Inputs: name (required), role (required), prefix (required), feature (required), +6 more. Returns: object

propose_claimC

State a falsifiable claim as a trace check (expect: symbol per step, null = any).

Inputs: kind (required), expect (required), inputs (required), feature (required), +4 more. Returns: object

record_unknownC

Record something that could not be observed (missing coverage is unknown, not absence).

Inputs: feature (required), question (required), recommended_probes. Returns: object

release_specA

Release a draft through the gate. Strict mode: succeeds only once a person has approved every finding and acknowledged coverage gaps (teardown approve); rewrite prose findings instead of waiting for approval. Standard mode: refused while measured coverage items are neither exercised nor explained, unless accept_gaps gives the reason they ship as unknowns.

Inputs: draft_id (required), accept_gaps. Returns: object

retract_ruleB

Retract one of your rules (e.g. superseded by a reworded version), with a reason. Rule ids are in check_rules results.

Inputs: reason (required), feature (required), rule_id (required). Returns: object

review_specB

Run the gate on a draft without releasing it: findings grouped by class (expected-output / interface / prose), which are approved, and prose findings in full.

Inputs: draft_id (required). Returns: object

run_sequenceB

Reset the target, apply the inputs, and return raw observations and symbols. symbols_only drops the raw observations; keys (e.g. ["path", "status", "alerts"]) keeps only those parts of each symbol.

Inputs: inputs (required), keys, symbols_only. Returns: object

set_mapperC

Replace the mapper rules (drop/mask/rename/classify). Creates a new mapper version.

Inputs: note, rules, params. Returns: object

suggest_probesB

Concrete next steps for the feature's coverage gaps: fault actions with a path that makes the call, probe_web_field arguments for unprobed fields, click paths for unexercised controls. Run after discover_ui and after each batch of rules.

Inputs: feature (required), limit. Returns: result

update_unknownB

Mark an unknown resolved / out-of-scope / investigating (or reopen it) with a note. Resolved unknowns leave the release; the audit log keeps the history.

Inputs: status (required), unknown_id (required), note. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.8/5.0

    Scored across 31 tools

    Disambiguation3/5

    Most tools map to distinct workflow stages such as open_target, discover_ui, probe_web_field, and release_spec, but rule/claim checking and the multiple list_* introspection tools overlap conceptually. An agent may struggle to choose between check_rules/propose_claim/falsify_claim or list_rules/list_claims, and the large surface increases misselection risk.

    Naming Consistency4/5

    Names are predominantly verb_noun (retract_rule, probe_cli, review_spec), with only coverage, blocked_hosts, and api_contract as noun-only exceptions. The probe_web_field versus probe_cli split is a minor inconsistency but overall the naming is predictable.

    Tool Count2/5

    31 tools exceeds the 25-tool threshold and includes several narrow introspection/listing tools such as list_claims, list_rules, list_feature_unknowns, list_tickets, blocked_hosts, and api_contract that could be consolidated. The multi-target workflow explains some breadth, but the surface is heavy for an agent to manage.

    Completeness4/5

    The surface covers target intake, UI/CLI discovery, field/CLI probing, sequences, flows, rules/claims, coverage, unknowns, docs, spec compile/review/release, tickets, audit, and mapping. Minor gaps exist around session/target listing or closing and claim lifecycle cleanup, but the core teardown-to-release workflow is well supported.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables passive reconstruction of an application's HTTP endpoints, WebSocket/event surfaces, payload schemas, and process architecture purely by observing labeled traffic, logs, and process metadata — never by sending requests to the target. Findings carry evidence levels and confidence, and can be exported as OpenAPI, AsyncAPI, JSON Schema, protocol catalogs, architecture maps, and candidate MCP capability surfaces.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables agents to take software apart over MCP — native binaries, Go/Rust/.NET assemblies, WASM and EVM bytecode, Android and Flutter apps, firmware, databases, crashes and network captures — returning findings backed by code, references and explicit unknowns. Drives deep-analysis engines such as Hopper, Ghidra, IDA, JADX and Frida entirely locally, letting agents explain behavior or rebuild a feature in your own project.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to turn authorized software artifacts into verified working reimplementations through behavioral capture, clean-room synthesis, differential parity verification, and evidence-pack export. It supports CLI binaries and HTTP APIs, with policy controls and vector fuzzing.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to reverse engineer native binaries, JavaScript/Electron applications, .NET assemblies, web captures, EVM bytecode, and process behavior through a provider-neutral MCP interface. Every result is an evidence envelope stating what was observed, derived, unexamined, or unprovable, with all capabilities gated by a deterministic fail-closed policy engine.
      Apache 2.0