# Rules for coding agents in this repository Freehand itself loads this file into the first message of a session started here. Other agents that read `AGENTS.md` do the same. ## Commands ```bash uv sync --extra dev # set up uv run pyflakes src tests .github/scripts # lint; must print nothing uv run pytest -q tests/test_runtime.py -k # targeted test (fast: run this while iterating) uv run pytest -q tests/test_web_e2e.py --require-browser # targeted real-browser test file # Broad local core check (3 parallel shards, ~1.5-2 min); avoid single-threaded `pytest -q` (~15 min with Chrome): uv run --no-sync python .github/scripts/ci.py parallel --shards 3 -- uv run --no-sync pytest -q --suite=core ``` While iterating locally, run `pyflakes` and only the directly affected test file(s); leave the full cross-OS and full browser suite to GitHub CI rather than running single-threaded `uv run pytest -q` after every edit. When changing `src/freehand/runtime/`, verify stdlib-only Python 3.9 imports: ```bash uv run --no-project --python 3.9 python -I -c \ "import sys; sys.path.insert(0, 'src/freehand/runtime'); import agent, providers, auth, shellenv, wsclient, calltrace" ``` When changing `desktop/`, run `python3 ../.github/scripts/npm_audit.py`, `npm run test:build-deps`, and `npm run test:updates` inside `desktop/`. ## Layout - `src/freehand/runtime/`: the agent loop and providers. Standard library only, and it must import on Python 3.9, because it is copied into benchmark containers. Do not add a dependency or 3.10+ syntax here (`from __future__ import annotations` is what makes the type hints work). - `src/freehand/`: the command line and the interactive interface (prompt_toolkit, rich), Python 3.10+. - `src/freehand/control.py`, `server.py`, `web/`: the browser interface (`freehand web`). Standard library and plain JavaScript, no build step and no dependency. `desktop/` is an Electron shell around it and holds no agent code. - `src/freehand/mcp.py`: the MCP client behind `freehand mcp`. Servers are reached from bash; they are never turned into tools of the model. - `src/freehand/prompt.md`: the system prompt. - `tests/`: offline tests. `fakes.py` and `fake_providers.py` script the model APIs; `repl_driver.py` drives the interactive interface in a pseudo-terminal. ## Rules - What the model sees (`prompt.md`, the tool descriptions in `tool_specs`, the status line, harness notes, the first message's context block in `session.context_block`) is not changed as part of another task. Ask first. - Do not add a feature that decides something for the model: no plan mode, todo tool, sub-agent tool, automatic compaction or approval prompt. - A change in behaviour comes with a test. Never call a real model API from a test. - The version lives in four places that must match: `__version__` in `src/freehand/__init__.py`, `VERSION` in `src/freehand/runtime/agent.py`, `version` in `desktop/package.json`, and `desktop/package-lock.json`. - Do not edit `CHANGELOG.md` in ordinary pull requests; maintainers update it at release time to avoid merge conflicts. - Lines are at most 120 characters. Comments say why, not what. - Never write credentials, tokens or the contents of `~/.freehand/auth.json` to a log, transcript or test fixture. - Do not commit temporary debugging or reproduction artifacts (such as local `reproductions/` scripts or screenshots). - After implementing a feature and verifying that its tests pass, commit your changes for that feature. - Commit only your own changes; leave unrelated or pre-existing changes untouched unless explicitly asked to include them. - Do not push or tag unless asked.