Architecture
The parts of screw-bugs, and what happens from an agent's request to a finished report.
screw-bugs is a CLI and an MCP server around a platform-free engine. It has no AI of its own: your coding agent writes the cases, and screw-bugs runs them in a real headless browser and decides every status in code.
The parts
src/ holds one folder per module. schema, core and report are their own package, @screw-bugs/core, which screw-bugs re-exports.
| Module | Owns | Code |
|---|---|---|
schema | Schemas of every file a run reads or writes: JobSpec, CaseLedger, ReportBundle, Findings | packages/core/src/schema/job.ts |
core | The engine (Engine, runCase) and the services it runs on: Browser, Storage, ReportRenderer, AccountBook | packages/core/src/core/engine.ts |
report | The renderers: renderHtmlReport, renderWalkthrough, renderPrSummary, renderLivePage | packages/core/src/report/html.ts |
browser-playwright | The Browser service on Playwright: launches Chrome, Edge or Chromium, runs steps, takes screenshots, records video | src/browser-playwright/launch.ts |
store-local | The Storage and AccountBook services on disk, under .screw-bugs/ | src/store-local/storage.ts |
cli | The CLI commands, the MCP server, the local report server and the sign-in live view | src/cli/mcp.ts |
Why the split
@screw-bugs/core depends only on effect: no Node, no Playwright. pnpm lint and pnpm check:workers keep it that way, so it runs on Cloudflare Workers.
The life of a run
- Plan. The agent writes a job: a URL, a
summary, and cases of structured steps. - Start. It calls the MCP tool
start_run(or you runscrew-bugs run --spec job.json). The reply is a job ID, right away. - Record. The engine saves
job.jsonand startsledger.jsonin.screw-bugs/runs/<job-id>/. - Run. Cases run in order, in one browser session. Each step acts, waits or checks; screenshots and one continuous video are saved as it goes.
- Judge. Code sets each case to
passed,failed,blockedornot_verified. A live page,live.html, follows the run. - Report. When the run ends it writes
evidence.json,report.htmlandwalkthrough.html. - Review. The agent reads the evidence pack from
run_status, then sends its write-up withsubmit_findings. - Re-render. screw-bugs checks the write-up against the run, saves
findings.json, drawsannotated/screenshots and writes the report again.
agent ──start_run──▶ MCP server ──▶ Engine ──▶ Browser (Playwright, headless)
│ │
▼ ▼
.screw-bugs/runs/<job-id>/ evidence/ video/
job.json ledger.json evidence.json
│
agent ◀──run_status── evidence pack ◀─┘
agent ──submit_findings──▶ findings.json ──▶ report.html + walkthrough.htmlHow Cloud reuses it
screw-bugs Cloud runs the same engine from @screw-bugs/core on Cloudflare Browser Run, and renders shared reports with its renderers. See Cloud runs.