The hooks
Takt adds two hooks to Claude Code and Codex. The session-start hook protects each session and tells the agent about the fleet. The command hook moves heavy work out of the session into Takt jobs. The skill tells agents what to send to Takt; the hooks make sure, even when an agent forgets.
When a session starts
takt hook session-start protects the new session, so that when memory runs short, Takt’s jobs stop before it (on Linux). Then it tells the agent two things:
Takt: this session is protected: when memory runs short, Takt's jobs stop before it. 4 of the fleet's 9 machines are ready for jobs.
Takt: webapp has an image (.devcontainer/devcontainer.json), so its jobs run on any machine that fits.
When the project has no image, the second line says to create .devcontainer/ before running jobs, since Takt would run them only on this machine. See Project images.
What the command hook does
When an agent starts heavy work in its own session, such as a test suite or a build, the hook moves that command into a Takt job. Pipes and redirections still act on this machine, and the line exits with the job’s exit code. It runs for every session, subagents and headless claude -p runs included.
bundle exec rspec spec/upload_spec.rb | tail -20 > out.txt
runs as
takt run --name "webapp: upload_spec" --from-hook command -- bundle exec rspec spec/upload_spec.rb | tail -20 > out.txt
Before it runs, the agent reads that the command was moved into a Takt job, which runs its uncommitted changes and may take a few minutes on its first run. The job’s first line names it: takt: ran this as Takt job <id>.
It is a PreToolUse hook on the shell tool, takt hook pre-tool. In Claude Code, the rewritten line goes through the session’s usual permission prompts. Codex takes a rewritten command only together with an allow, so there the hook allows it.
What it moves
| Moved into a Takt job | Runs as usual |
|---|---|
Test runners, even for one file: bin/rails test, rspec, cargo test, go test, pytest, npm test, vitest, playwright test, xcodebuild |
git, gh, grep, cat, sed, ls and other reading and searching |
Builds: cargo build/check/clippy/run, make (no target, or test, build, check, all, ci…), Gradle, Maven, Bazel, swift build, npm run build |
go build, go vet, go run, gofmt, cargo fmt |
Containers: docker/podman build, run, compose up |
docker ps, docker exec, docker logs |
Browsers (chromium, playwright, cypress), servers (bin/dev, rails server, npm run dev), databases, emulators |
Linters and formatters on files: rubocop, eslint, ruff |
Renders (hyperframes render, blender -b) and evals (promptfoo eval) |
npm ci, ffprobe, --help and --version of anything, and listings that run nothing (rake -T, bin/rails -T, playwright test --list) |
Anything already through Takt: takt run ..., takt wait |
What carries over into the job:
| On the line | In the job |
|---|---|
A cd earlier on the line |
The same folder |
| Variables set before the command | Passed with --env NAME, so their values never show |
xcodebuild |
--feature darwin |
A run that writes back into the checkout: jest -u, --update-snapshots, -update, cargo insta, UPDATE_SNAPSHOTS=1 |
Runs --here, in the checkout itself |
The hook looks through &&, pipes, bash -c '...', heredocs, bundle exec, npx, uv run, timeout, nohup, setsid and the like.
It also reads the local scripts a command runs, up to 64 KB: a shell script by the same rules, and a node or python3 script as a browser when it launches one through Playwright, Puppeteer or Selenium. A script that sends its work to Takt itself runs as usual.
A command inside a Takt job is the job’s own work and runs. If the hook can’t read the event, it lets the command run. So does every command of a session that sees no fleet: one on a machine that hasn’t joined, or one with a HOME of its own, such as a bot’s sandbox.
Git hooks
A git command that runs a repository hook (git commit, git merge, git rebase --continue, git am, git push) is checked for what that hook runs. Takt reads the hook file, and the commands of Lefthook, Overcommit, Husky and the pre-commit framework.
When the repository’s hook would start a test suite or a build, Takt runs its checks as a Takt job, then the git command with the hook skipped. The commit happens only when the checks pass:
{ takt run --name "webapp: pre-commit checks" --from-hook pre-commit/commit -- bundle exec rubocop && bin/rails test && git commit --no-verify -m "Fix upload limit"; }
| When | What happens |
|---|---|
The hook changes files (a formatter that fixes them, lint-staged, a git add) |
The checks run --here, in the checkout, since a job on a snapshot can’t write back |
Takt can’t make the checks one command (a long script in .git/hooks) |
The git command is denied, with the two lines to run instead |
--no-verify, or a hook that is missing, not executable, or only does quick checks |
The git command runs as usual |
When it denies instead
Where a line can’t be rewritten in place, the hook denies it and gives the exact command to run:
| The line | The agent gets |
|---|---|
Heavy work inside bash -c '...' or a heredoc, or over ssh |
The takt run line to use |
| A sleep loop that waits on a Takt job | takt wait <id> |
A loop that greps takt logs <id> for a line |
takt logs <id> --until '<regex>', with its pattern filled in |
Takt: this starts a test runner in your session. [...] Run it as:
takt run --name "webapp: upload_test" -- bin/rails test test/system/upload_test.rb
To have the hook deny every heavy command instead of moving it, set TAKT_HOOK=deny in the environment (every project), or hook: deny in a project’s takt.yml.
When a session is at its memory cap
On Linux, the hook also tells an agent when its own session is stalled at its memory cap. The command still runs, and the agent reads beside it:
Takt: this session is at its memory cap (12.5G of 12G, 98% stalled), so everything in it, you included, runs slowly while the machine has memory to spare. The biggest processes here are: pid 41022 ruby bin/minitest-queue (3.1G); [...]. Move that work to `takt run` and stop them by their exact pid.
It speaks when the session’s scope is within 5% of its memory limit and its processes all waited for memory at least 20% of the last 10 seconds. Below that, it says nothing.
Turning it off
| To | Do |
|---|---|
| Keep some commands in the session, such as fast unit tests | List them under local in the project’s takt.yml |
| Refuse heavy commands instead of moving them | TAKT_HOOK=deny, or hook: deny in takt.yml |
| Remove the hooks, the skill and the MCP server | takt skill remove. takt skill install adds them back. |
takt skill remove and takt uninstall leave the agents’ other hooks alone.