Skip to main content

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


A confined observer studies the target's behavior through CRAB's drivers; the gate releases a sanitized spec; a confined clean agent rebuilds the feature and gets abstract verdicts back




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).

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

Which agents can use CRAB?

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.

Does CRAB read the target's code?

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.

How is the clean side kept clean?

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.

What about the model's own memory?

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.

Does CRAB upload my app?

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

Is reimplementing a product this way legal?

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.

Metadata

Release files for crab-cleanroom 0.4.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 crab-cleanroom 0.4.0
File Size Uploaded Provenance Actions
crab_cleanroom-0.4.0.tar.gz 321.6 kB With provenance Details for crab_cleanroom-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for crab-cleanroom 0.4.0
File Interpreter ABI Platform Actions
crab_cleanroom-0.4.0-py3-none-any.whl Python 3 none any Details for crab_cleanroom-0.4.0-py3-none-any.whl

Total release size: 579.5 kB

Release files / crab_cleanroom-0.4.0.tar.gz

Download URL crab_cleanroom-0.4.0.tar.gz
Size 321.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8fc521a4e0260ba8699bc6e4d0ee22d19dc672e75226ae7238875428e719749e
BLAKE2b-256 checksum
How to use checksums
75f2f7bd8bbf0f9aaa20a8515450645e01df8905bc1f275a91004c9be3c7f4c7
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 3, 2026.

Transparency log

Release files / crab_cleanroom-0.4.0-py3-none-any.whl

Download URL crab_cleanroom-0.4.0-py3-none-any.whl
Size 257.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d602f78b09003c5cfdc85de0999a4693bb13a106f033cd8d545b18773da0c04
BLAKE2b-256 checksum
How to use checksums
6430af8cdd4eca35090538be8650b43f6cea80634e557e805e38f71a88ac29d8
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 3, 2026.

Transparency log

Security for crab-cleanroom 0.4.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for crab_cleanroom-0.4.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 3, 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.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files Full provenance

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