Turn a mitmproxy flow capture into a standalone Python CLI workspace with commands, fixtures, processors, goldens, tests, and a refinement skill for your coding agent.
- π§ What is autocli?
- π Requirements
- β‘ Get Started
- π Workflow
- π¦ Generated Workspace
- π§ͺ Generated Workspace Behavior
- β¨οΈ Command Reference
- π οΈ Develop autocli
autocli is a factory for building per-site command-line tools from recorded browser traffic.
It compiles a mitmproxy flow capture into a standalone Python workspace. The generated workspace is intentionally editable: it gives you the first draft of commands, fixtures, request processors, response processors, goldens, tests, and a workspace-local runtime. From there, the normal flow is to refine the generated CLI shape with AI assistance until it feels like a real user-facing tool.
- Python 3.12+
- uv
Install autocli from the repository:
uv tool install autocli --from git+https://github.com/alex-j-b/autocli.gitOr, while developing locally:
uv tool install --editable .Record browser traffic with mitmweb, filter it down to the requests you want to keep, and export the selected flows to capture.flow.
Build a workspace from a mitmproxy capture:
autocli build capture.flow --output-dir <workspace_cli>Then refine and run the generated CLI:
cd <workspace_cli>
# Use skills/build-cli/SKILL.md with your coding assistant to finalize the CLI shape.
uv tool install --editable .
uv run pytest -q commands/<command-id>/tests/test_command.py
<workspace_cli> --helpUse mitmweb, mitmproxy's browser-based UI, to record and inspect browser traffic.
First-time setup: after mitmweb is running and your browser is using it as an HTTP(S) proxy, open http://mitm.it and install/trust the mitmproxy CA certificate for your OS/browser. This is required to decrypt HTTPS traffic; see mitmproxy's certificate docs.
Typical macOS workflow:
-
Start
mitmweb, limiting capture to the target host (e.g.amazon.com):mitmweb --listen-host 127.0.0.1 --listen-port 8080 --web-host 127.0.0.1 --web-port 8081 --allow-hosts '(^|\.)amazon\.com:443$' -
Route Wi-Fi web traffic through mitmproxy:
networksetup -setwebproxy "Wi-Fi" 127.0.0.1 8080 && networksetup -setsecurewebproxy "Wi-Fi" 127.0.0.1 8080 && networksetup -setwebproxystate "Wi-Fi" on && networksetup -setsecurewebproxystate "Wi-Fi" on
-
Open the mitmweb UI at
http://127.0.0.1:8081, perform the browser actions you want to turn into CLI commands, then filter out unrelated flows. -
In mitmweb, choose File -> Save filtered and save the result as
capture.flow. -
When finished, disable the macOS proxy settings for Wi-Fi.
networksetup -setwebproxy "Wi-Fi" 127.0.0.1 8080 && networksetup -setsecurewebproxy "Wi-Fi" 127.0.0.1 8080 && networksetup -setwebproxystate "Wi-Fi" off && networksetup -setsecurewebproxystate "Wi-Fi" off
Generate a new workspace from a flow capture.
autocli build capture.flow --output-dir <workspace_cli>Use skills/build-cli/SKILL.md with your coding assistant to review generated commands, rename or merge noisy captures, shape arguments and output contracts, implement processors, and approve goldens.
autocli build prints the path to the generated refinement skill.
That refinement workflow is designed to:
- inspect generated commands and fixtures
- identify duplicates and awkward capture-derived names
- reshape the CLI around user-facing concepts and propose it for approval
- implement each command one by one, including
processors/pre.pyandprocessors/post.py - update goldens and run focused tests until the final command set is accepted
- approve or give feedback on each command
Run generated contract tests, inspect help output, and execute live commands when needed.
The installed CLI name is set from the output directory name, normalized to kebab-case, and stored in [tool.autocli].executable_name. You can customize it with --executable-name my-cli.
For example, --output-dir my-workspace-cli creates a workspace that installs a my-workspace-cli executable after running:
uv tool install --editable .Every generated workspace includes:
<workspace_cli>/
βββ pyproject.toml # Workspace metadata and installed CLI name
βββ <site_module>/ # Generated runtime and test helpers
βββ skills/
β βββ build-cli/
β βββ SKILL.md # Refinement workflow for your coding agent
βββ commands/
βββ <command-id>/
βββ command.yaml # Command metadata, request mapping, completion flag
βββ fixtures/
β βββ <case-id>/ # Representative captured request/response fixture
βββ goldens/ # Approved post-processed output
βββ processors/
β βββ pre.py # Request shaping
β βββ post.py # Output shaping
βββ tests/
βββ test_command.py # Generated offline contract test
The first build must target an empty output directory. Later runs into the same generated workspace are append-only: new command trees are added, and existing ones are left in place.
Generated workspaces are editable CLI projects. They contain the generated runtime, command definitions, fixtures, processors, tests, and local agent guidance needed to refine a site-specific CLI.
- Generated command names, arguments, and output shapes are a first pass, not the final UX.
- Every generated command starts incomplete and is hidden from normal CLI discovery.
- Running a command's generated contract test updates its completion flag.
- Only completed commands are registered in normal CLI help and execution.
--rawreturns the unprocessed response body.
- Generated tests stay offline: they call the generated CLI with
--replay, which uses fixture responses instead of making network calls. --replayis only available whenAUTOCLI_TEST_MODE=true.
- Session-sensitive headers are stripped from generated fixtures and command definitions.
- For normal live runs, store browser-session headers in the system keyring with
<workspace_cli> auth store-headers. - The generated CLI reads those keyring headers at runtime and merges only session-sensitive headers into live requests.
PLAYWRIGHT_HEADERS_JSONis only a generated CLI runtime override. Use it for temporary manual runs or CI when the keyring is unavailable.- If both are present,
PLAYWRIGHT_HEADERS_JSONtakes precedence over the keyring.
autocli build capture.flow --output-dir <workspace_cli>autocli build capture.flow --output-dir <workspace_cli> --executable-name my-clicd <workspace_cli>
uv tool install --editable .
<workspace_cli> --help
<workspace_cli> <command path> --helpcd <workspace_cli>
<workspace_cli> <command path>cd <workspace_cli>
uv run pytest -q commands/<command-id>/tests/test_command.pyuv run pytest -q
uv tool install --editable .