Status: experimental alpha. The tool and the skill were built in September 2026 and have few real runs so far. The command line and the file formats can change.
This project makes cheap opencode subagents usable from Claude Code. Its name is idfix 🐕, after the dog Idefix in Asterix, because it will support clients other than opencode. Until 2026-10-05 its name was opencode-subagents. It contains a small command line tool idfx and a Claude Code skill idfx, packaged as a Claude Code plugin. The old name of the tool was oc-sub. It is no longer a command, and idfx is the only command name. The research of the design is in .plan/research/prior-art.md. The lessons from the first use are in .plan/EXPERIENCE.md.
The repository is a Claude Code plugin and a plugin marketplace. Install it once:
claude plugin marketplace add thoka/idfix
claude plugin install idfix@idfix
You need no agent file in the project: the plugin serves the coder, researcher, and reader agents itself, through OPENCODE_CONFIG_DIR. docs/GUIDE.md explains the setup, how to watch a run live, how to follow up and abort, how to read the cost, and the security notes.
The manifest has no version field, so Claude Code uses the git commit as the version, and every pushed commit counts as an update. Claude Code does not update a third-party marketplace by itself. To get the new commits, run these commands and then start a new Claude session:
claude plugin marketplace update idfix
claude plugin update idfix@idfix
To update at every start instead, open /plugin, select the marketplace, and enable auto-update. On the machine where you develop the plugin, add the marketplace from the local folder (claude plugin marketplace add /path/to/idfix). Claude Code then reads the files live, and /reload-plugins loads a change. .plan/research/plugin-updates.md has the sources.
.claude-plugin/plugin.json— the plugin manifest (nameidfix).claude-plugin/marketplace.json— a marketplaceidfixthat lists this folder as the pluginskills/idfx/SKILL.md— the skill: when to delegate, the workflow, and the rulesskills/idfx/reference.md— the full command reference and the detailsopencode/agents/— the agents of the plugin:coder,researcher, and its hidden subagentreader.idfx upserves them throughOPENCODE_CONFIG_DIR.bin/idfx— the launcher ofidfx. The link~/.local/bin/idfixalso calls it. Claude Code putsbin/on the PATH of its Bash tool while the plugin is enabled. The launcher finds bun (or gets it through mise), runsbun install --frozen-lockfile --productiononly whenbun.lockorpackage.jsonchanged (a stamp innode_modulesholds their checksum), and runssrc/cli.ts. A call with no change prints nothing to stderr.
Check the plugin with claude plugin validate . and claude --plugin-dir . plugin details idfix.
Install the tools with mise, then the packages with bun:
mise install
bun install
mise run hooks-install # once after clone: the pre-push hook runs the tests
The project gives only its start script bin/idfx. It does not link it into a folder on your PATH. To use it from any folder, link it yourself, for example ~/.local/bin/idfx and ~/.local/bin/idfix, or let your dotfiles manager make the links. Both links point to bin/idfx. The launcher follows a symlink back to this repository, so updates to the repository take effect at once. The help and the usage hints show the name that you called, for example idfix for a link ~/.local/bin/idfix to bin/idfx. The launcher passes the base name of its $0 in the variable IDFX_PROG. Without it, the CLI uses idfx.
mise.toml pins bun, opencode, and lefthook. Check the setup with:
mise run test # bun install --frozen-lockfile, typecheck, then bun scripts/test-card.ts (bun test, ends with a verdict card)
mise run test is also the pre-push hook. lefthook.yml defines it, and mise run hooks-install (lefthook install) installs it into .git/hooks. A push runs the tests on your machine first, and a failed test stops the push. If git-autopush is on the PATH, the hook runs the tests through git-autopush tests: it waits for a free test slot of the machine and skips a tree that passed before. The task first runs bun install --frozen-lockfile each time. A fresh git worktree has no node_modules, and a merge can add a package to bun.lock. With no change, the install takes a few milliseconds. Without this step, a test can leave a partial node_modules, and the Ink tests then fail with two copies of React.
The file .git-autopush-untested lists the paths that no test reads, such as AGENTS.md, LICENSE, and the probe notes. git-autopush leaves these paths out of its test key. So a push that changes only these paths reuses an earlier pass and runs no new suite. Before you add a path, prove it: remove the listed files in a throwaway clone and run mise run test there.
This repository is public, so its tracked files name no local path of a developer and no private project. The pre-commit hook runs public-check on the staged files when that tool is on your PATH, and else prints a note and passes. test/public.test.ts checks the paths of all tracked files in every test run, also without the tool. The file .public-check-allow lists the exact strings that both checks allow, for example the example home folder /home/user of the tests.
The CLI has the name idfx. oc-sub was its old name, and it is no longer a command. test/old-name.test.ts fails when a file in src/, this README, docs/GUIDE.md, or the skill names the old name with a command, and it names each file and line. It also fails when bin/oc-sub exists or package.json lists an oc-sub bin.
idfx drives an opencode server: start it, launch subagent runs, watch them live, and read the results. Entry point: src/cli.ts. Run it with bin/idfx, bun run src/cli.ts, or bun src/cli.ts. With the plugin enabled, Claude runs it as idfx.
The server URL comes from --url or the environment variable IDFX_URL, default http://127.0.0.1:8767. up, down, and restart run the server in sandbox mode by default (one Docker Sandbox per project, in clone mode: the agent works in a private clone of the repository; see docs/GUIDE.md). --no-sandbox selects the host server, which the sections below describe. --port N and --url URL name a host server, so they imply --no-sandbox. With --port N, they target port N and keep the host of the URL; a --url flag whose port differs from --port is a usage error. When OPENCODE_SERVER_PASSWORD is set, every request uses HTTP basic auth (username from OPENCODE_SERVER_USERNAME, default opencode, as opencode itself does). The secret is never printed. Every command except up, down, and restart first checks the health of the server. If no server answers within 2 seconds, status prints no server on <url> and exits with code 0. The other commands print error: no server on <url>. Start it with: idfx up and exit with code 1. If a server answers with HTTP 401 or 403, every command exits with code 1 and says that the server rejected the password in OPENCODE_SERVER_PASSWORD, or that it needs one. up then does not start a second server. Sessions belong to a project directory, so run needs --dir; status, ping, watch, log, abort, and answer take an optional --dir (default: the current directory). Run the commands from the same directory that started the run, or pass the same --dir.
The CLI had the name oc-sub before. Some names that live on disk or in the environment had that name too. They have new names now, and the old names in this table still work:
what: What
new-name: New name
old-name: Old name, still read
--
what: State folder
new-name: `$XDG_STATE_HOME/idfx/`
old-name: `$XDG_STATE_HOME/oc-sub/`
--
what: Project file
new-name: `.opencode/idfx.json`
old-name: `.opencode/oc-sub.json`
--
what: systemd user units
new-name: `idfx-<kind>-<port>` in `idfx.slice`
old-name: `ocsub-<kind>-<port>` in `ocsub.slice`
--
what: Log start marker
new-name: `--- idfx <label> <time> ---`
old-name: `--- oc-sub <label> <time> ---`
--
what: Cost proxy log source
new-name: `idfx-cost-proxy`
old-name: `oc-sub-cost-proxy`
idfx reads the new name first and the old name second. It writes only the new names. idfx doctor warns about each old name that is still in use (checks state-names and project-config-name), and idfx doctor --fix moves the state folder and renames the project file. Some names stay: the data folder $XDG_DATA_HOME/oc-sub/, because each sandbox mounts it by its path, the sandbox name oc-sub-<project>, its clone remote, and the label variables OCSUB_OWNER and OCSUB_REASON.
The environment variables are IDFX_URL, IDFX_OWNER, IDFX_SHARED_DIR, and IDFX_NO_SANDBOX. Their old names with the prefix OC_SUB do not work any more. A blank value counts as unset.
IDFX_NO_SANDBOX declares that this host runs no sandbox. Its value is a free reason text, for example no KVM on this machine. With the declaration, idfx doctor gives the checks kvm-access and sandbox-mounts the result skip ("skipped: host declares no sandbox"), and their fixes do nothing. Each command that creates or starts a sandbox (up, restart, run, say, worktree) stops with an error that names the variable, exits non-zero, and runs no sbx call. It never falls back to a run without a sandbox. Without the declaration, a Linux host with no /dev/kvm stays a fail. A blank or absent value declares nothing.
bun run src/cli.ts up [--dir DIR] [--idle-minutes N]
bun run src/cli.ts up --no-sandbox [--port N] [--idle-minutes N]
Checks the health of the host server (GET /global/health). When nothing answers, it starts opencode serve --port N --hostname 127.0.0.1 in the background (as a systemd user unit, so it outlives the command; see "Background processes" below), waits until it is healthy, and prints the URL and the version. Without --port, the port comes from the URL, then from 8767. With --port N, up checks and starts the server on port N and keeps the host of the URL (so IDFX_URL keeps its host). When both --url and --port are given and their ports differ, up stops with a usage error. Without --no-sandbox, up starts a sandbox instead (see docs/GUIDE.md).
up sets OPENCODE_CONFIG_DIR in the environment of the child process to the opencode/ folder of this repository (computed from the location of the source file, not from the working directory). opencode then loads the research agents of the plugin for every project, after the project .opencode folder, so its agent wins over a project agent with the same name. If the environment already sets OPENCODE_CONFIG_DIR to another value, up keeps that value and prints a warning to stderr, because the research agents are then not loaded. If OPENCODE_CONFIG_DIR already holds the folder of the plugin, up prints no warning.
up also needs the shared agents folder. Set IDFX_SHARED_DIR to it. There is no default. It holds your global rules in AGENTS.md and your skills in skills/<name>/SKILL.md. It is the only source, and up never copies it. When IDFX_SHARED_DIR is not set or blank, up stops before it starts anything, with an error that names the variable and what the folder must hold. When <shared>/AGENTS.md is missing, up stops with an error that names the path and IDFX_SHARED_DIR. Otherwise up sets OPENCODE_CONFIG_CONTENT for the child, with the rules file under instructions and the skills folder under skills.paths. The reason: opencode 1.18.32 drops the global ~/.config/opencode/AGENTS.md whenever OPENCODE_CONFIG_DIR is set, and up always sets it. An absolute path in instructions still loads (see .plan/research/opencode-rules.md). If the environment already sets OPENCODE_CONFIG_CONTENT, up keeps it and prints a warning, because the shared entries are then not added.
DeepInfra is an optional second model provider. When the project has the key file ~/.config/<project>/deepinfra.key, up sets it up: in sandbox mode the key stays on the host as a custom secret of sbx, and in host mode the server gets DEEPINFRA_API_KEY (the environment first, then the key file). A run picks it with --model deepinfra/zai-org/GLM-5.3-Flash. DeepInfra serves this model only in fp4 precision, see .plan/research/deepinfra.md. The setup and the cost log are in docs/GUIDE.md, section "DeepInfra as a direct provider".
One server serves many project folders, so its state lives in one folder per user, $XDG_STATE_HOME/idfx/ (default ~/.local/state/idfx/). Older versions used $XDG_STATE_HOME/oc-sub/. While that old path is a real folder, idfx keeps using it, so a running server keeps its PID file. idfx doctor --fix moves its entries into the new folder and links the old path to the new folder. The folder holds:
serve-<port>.logholds the output of the server.serve-<port>.pidholds its PID.serve-<port>.dirslists the folders thatidfx runsent sessions to.idfx downchecks these folders for busy sessions.idle-<port>.pidholds the PID of the idle watchdog of the server.serve-<port>.lockis the server lock.idfx runholds it while it starts a session, and the idle watchdog holds it while it stops the server. It is a folder, because the lock libraryproper-lockfilelocks withmkdir.runs/holds a copy of every run record, sowatchandlogfind the real cost from any working directory.
up starts each long-lived process as a transient systemd user unit (a user service that exists only while it runs). The name is idfx-<kind>-<port>, in the slice idfx.slice. The kind is serve (the host server), proxy (the cost proxy), holder (the sbx exec holder of sandbox mode), or idle (the idle watchdog). The description of each unit gives the owner (the project of the folder where you ran up) and the reason, for example owner=idfix reason=cost proxy for port 4096. The environment variable IDFX_OWNER overrides the owner, for example IDFX_OWNER=my-session idfx up. It changes only the label, not the project of the key files. A blank value keeps the project name, and white space in the value becomes _. The integration tests set IDFX_OWNER=test, and their teardown stops their units. Older versions named the units ocsub-<kind>-<port>. down, down --all, the idle watchdog, and doctor stop and list both names. List them with:
systemctl --user list-units 'idfx-*' 'ocsub-*' --all
down stops the units of its port first. A unit stop ends every process of the unit, also a child that left its process group. The manager starts the cost proxy again one second after each end, like the old sh loop, with no start limit. The PID files stay, because status and doctor read them. On a host without a systemd user manager (macOS, a container, WSL without systemd), up starts the same processes detached, as before, and the cost proxy runs in a sh restart loop. Each process also gets the variables OCSUB_OWNER and OCSUB_REASON on both paths. These two label names keep the old spelling, because IDFX_OWNER is the input that sets the owner.
After a new server is healthy, up also starts an idle watchdog in the background. The watchdog stops the server when it is idle, so an unused server does not run for days. It works in both modes.
- The server is idle when no session is busy and no event came for 30 minutes. A heartbeat of the server is not an event. The watchdog follows the event stream of all folders (
GET /global/event). A session counts as busy fromsession.statuswithbusyorretryuntilsession.statuswithidleorsession.idle. --idle-minutes Nsets the limit.0turns the watchdog off. The option also works withrestart.- Before the stop, the watchdog asks
GET /session/statusof each folder inserve-<port>.dirsand of each folder that the event stream named. A busy session resets the timer. - The watchdog stops the server the same way as
idfx downwithout--force: the busy check, then SIGTERM to the process group. In sandbox mode, it uses the stop ofidfx down, which also runssbx stop. So the VM stops too. - It writes one line with the reason into
serve-<port>.log, for exampleidle-stop port=8767 idle=30m, and then exits. - It also exits without a stop when the server PID file changes or disappears, or when the server does not answer the health check 3 times in a row. So it never outlives its server for long.
down,down --all, andrestartstop the watchdog after the server stops. A staleidle-<port>.piddoes no harm.- An
upthat finds a running server starts no watchdog. - The watchdog takes the server lock
serve-<port>.lockbefore its final check and keeps it through the stop. It does not wait for the lock. Whenidfx runholds it, a run starts a session now. Then the watchdog resets its timer and writes one line into the log. - After an idle stop, the next
idfx runstarts a sandbox server again (seeidfx run).
idfx down --no-sandbox [--port N] [--force]
Stops the server that idfx up started on the port. It reads the PID file and makes sure that the process is still opencode serve on that port. If a session in one of the listed folders is still busy, down lists it and stops with code 1. With --force, it stops the server anyway. Then it stops the unit ocsub-serve-<port>, the cost proxy, and the idle watchdog (see "Background processes"). For a server without a unit (an older idfx, or a host without a user manager), it sends SIGTERM to the process group of the server instead. Both ways wait up to 15 seconds before SIGKILL. Then down removes the state files. If no server runs, it says so and exits with code 0. If a server answers but idfx up did not start it, down does not touch it and exits with code 1.
down knows only the sessions that idfx run started. It does not see a session that you started in the opencode interface.
idfx down --all [--force]
Stops every server that idfx started: each sandbox with a state file that sbx ls shows as running, and each host server with a PID file serve-<port>.pid. Each server gets the same busy check as a single down. Without --force, a busy server stays up, and the other servers still stop. If one server does not stop, down --all exits with code 1. --all takes no other flag, and restart does not accept it.
idfx restart --no-sandbox [--port N] [--force] [--idle-minutes N]
Runs down and then up on the same port. If down fails, restart stops there. In sandbox mode (idfx restart without --no-sandbox), it restarts the sandbox of the project.
bun run src/cli.ts run --agent NAME --dir DIR (--brief FILE | TEXT) [--title T]
Creates a session for the directory DIR, sends the brief to the agent asynchronously (POST /session/:id/prompt_async), and returns immediately. The brief is either a file (--brief brief.md) or positional text. With --title T the session gets that title.
With --agent researcher, run appends the critical-research footer to the brief, after a blank line. It reads the footer from <IDFX_SHARED_DIR>/skills/critical-research/SKILL.md: the first fenced block after the heading ## The footer. The footer starts with a line --- and asks for a section "Critical analysis" with four points. A brief that already ends with the footer stays unchanged. If the skill file or the block is missing, run stops with an error that names the file. Other agents get no footer.
When the project has a sandbox state and you pass neither --url nor IDFX_URL, run sends the run to the sandbox server. It first checks with sbx exec NAME test -d DIR that DIR exists inside the sandbox clone. A worktree that git worktree add created on the host is not in the clone. In that case run stops with exit code 1 before any session exists, and it names the two fixes: idfx worktree STEP, or a host server with --url. Without this check, opencode fails the prompt with NotFound: FileSystem.realPath, and the session ends idle without an answer.
When run uses the sandbox server in this way and the server does not answer GET /global/health, run starts it first. It runs the same steps as idfx up for the project, with the defaults, so the idle watchdog starts too. It prints started the sandbox server of <project> (it was down) to stderr and goes on. The output of the start also goes to stderr, so the session ID stays the first line on stdout. If the start fails, run stops with the error and the exit code of up. The start comes before the folder check, because that check runs sbx exec in the sandbox. With --url, with IDFX_URL, or without a sandbox state, run starts nothing and keeps its old error for a server that is down.
run holds the server lock serve-<port>.lock in the state folder from its health check until the prompt of the new session is sent. It releases the lock also on an error. The lock keeps the idle watchdog from stopping the server while a run starts a session on it. It also keeps two runs from starting the same sandbox server twice: the second run waits up to about one minute for the lock. If the lock stays held, run stops with an error that names the lock. A lock of a dead process counts as stale after 10 seconds, and the next run takes it over.
Before it creates the session, run checks the OpenRouter key. Each project needs its own key. The run directory must use its project key file ~/.config/<project>/openrouter.key, and no directory of another project may resolve to the same key. The known directories come from the same sources as status --all: the folders of past runs, the projects of the server, and their git worktrees. A directory of the same project may share the key, because it has the same git common dir. When another project shares the key, or when the run directory uses the global key from auth.json or the environment, run stops with exit code 1 before any session exists. The message names the other project and tells you to create ~/.config/<project>/openrouter.key for one of the projects and to run idfx restart. A directory that cannot be checked prints warning: <directory>: <message> to stderr and does not stop the run.
run also reads the cumulative usage of the key at OpenRouter (GET https://openrouter.ai/api/v1/key, which costs nothing) for the start value of the real cost (see watch and log). If OpenRouter does not answer, the run still starts.
The command prints, one per line:
- the session ID (so
idfx run ... | head -1gives it to a script), - the short
idfx attach CODEhint for a person to watch the run live (CODE is the last 6 characters of the session ID), - the path of the run record in the current directory,
- the path of the run record copy in the state folder.
The run record is a JSON file .opencode/runs/<session-id>.json in the current directory, with the session ID, directory, agent, title (null when unset), and start time. It also holds the first 8 hex digits of the SHA-256 of the key (keyFingerprint, never the key) and the key usage at the start in USD (usageAtStart, null without an answer). A copy goes to ~/.local/state/idfx/runs/ (or $XDG_STATE_HOME/idfx/runs/), so watch and log find the record from any working directory.
The record also names the agent CLI of the run in driver. run writes "opencode". A record without the field is an opencode record. The other names are "claude-glm" and "claude".
bun run src/cli.ts run --driver claude --dir DIR (--brief FILE | TEXT) [--title T] [--model MODEL] [--sandbox NAME]
Runs Claude Code headless (claude -p BRIEF --output-format json) in the Docker Sandbox claude-<project>, in the folder DIR of its clone. The command blocks until the run ends; there is no background mode yet. --driver picks the agent CLI, because --agent names an opencode agent (and Claude Code has an --agent flag of its own). So --driver claude takes no --agent and no --url, and --agent claude without --driver gives a usage error that names --driver claude. --model takes a Claude Code model name or alias such as sonnet. --sandbox NAME uses an existing sandbox instead of claude-<project>.
Start the command in the host checkout of the project (or a host worktree of it). The project and the repository of sbx create are the main checkout of the git repository of the current folder, never DIR: DIR is a path inside the sandbox. The sandbox holds its private clone at the host path of the checkout, so the root of the clone is the same path as the checkout on the host. A worktree in the sandbox usually does not exist on the host. Outside a git repository, the command stops before any sbx call. The doctor gate also checks the current folder. The clone check after a create runs git -C DIR rev-parse --git-dir inside the sandbox.
The steps:
- When
sbx lsdoes not list the sandbox,runcreates it in clone mode from the host repository of the current folder, with the state folder of the sandbox as a writable mount. Then it checks withgit -C DIR rev-parse --git-dirinside the sandbox that the clone exists. An existing sandbox must mount its state folder; elserunstops and tells you to remove the sandbox, so that the next run creates it with the mount. - It checks with
sbx exec NAME test -d DIRthat DIR exists in the clone. - It syncs your Claude configuration into the state folder (see the guide, section "The Claude Code state folder of a sandbox").
- It writes the run record with
status: "running", so thatstatusandabortfind the run while it blocks. - It runs Claude Code with
CLAUDE_CONFIG_DIRset to the state folder and a session ID that idfix picks (--session-id <uuid>).
On success, it prints the session ID, the cost line, the transcript path, the two run record paths, and then the answer of Claude Code. The cost is total_cost_usd of the result JSON: the API price of the tokens. On a Max plan, the run costs nothing extra, so the cost line calls it an API-equivalent estimate.
A run fails with exit code 1 when sbx exec ends with a code other than 0, when the result JSON is missing or has is_error: true, or when the answer is a short usage limit message (for example usage limit reached). The real form of a limit stop is not known yet. A failed run also writes a record under the session ID of the start. When idfx abort stopped the run, the record says aborted, and the run exits with code 1.
The record of a Claude run has driver: "claude", agent: "claude", and a claude object: sandbox, stateDir, model (the --model value, else the first model of modelUsage), status (running, ok, failed, or aborted), error, exitCode (null while a turn runs), isError, subtype, numTurns, durationMs, costUsd, costKind (always api-equivalent-estimate), usage, transcript (<stateDir>/projects/<folder>/<session>.jsonl, or null), endedAt (null while a turn runs), and resumeId (only when Claude Code answered with another session ID). numTurns, durationMs, costUsd, and the numbers of usage add up over the turns of run and say.
The session commands of a Claude run (they find the run record in the state folder, so they work from any folder):
say SESSION TEXTruns one follow-up turn,claude -p TEXT --resume SESSION --output-format json, in the same sandbox, state folder, and folder, after the same configuration sync. Unlikesayof opencode, it blocks until the turn ends, and then prints the session ID, the cost of the turn, the session total, the transcript path, the record path, and the answer.--modelpasses a model;--agenthas no effect. A session whose record saysrunningis refused.abort SESSIONrunssbx exec <sandbox> pkill -TERM -f '[c]laude .*SESSION', so it stops theclaudeprocess of the session in the sandbox, and marks the recordaborted. The blockingrunorsayin the other terminal then ends with exit code 1 and keepsaborted. Without a process, a record that saysrunningis markedabortedtoo (the run on the host was gone); an ended record stays, and the command exits with code 1.log SESSIONprints the last answer from the transcript in the state folder, one token line (tokens in, out, thinking, cache read, cache write, from the transcript), one line with the status and the turns, and the cost line of the record. The state folder is untrusted data:logfollows no link and reads at most the last 32 MiB of the transcript.statuslists the run with the statebusy(running),idle(ok),failed, oraborted, while it runs and for 60 minutes after its end.topshows the run from its record, with the state, the model, the tokens, and the API-equivalent cost from the transcript (read likelog), and two guards while it runs:loopingwhen the last 5 tool calls have the same tool and input, andstalledwhen the transcript did not change for 3 minutes. The thresholds and the loop key are the ones of the opencode guard (src/detect.ts). A guard only marks the row; it never stops the run. The code is insrc/claude/sandbox-rows.ts.watchdoes not work for Claude runs yet.
A driver is the code that runs one agent CLI. src/driver.ts keeps the drivers in a registry. Each driver implements the commands run, say, abort, watch, and log. run uses the opencode driver, or the claude driver with --driver claude. say, abort, watch, and log load the run record of the session from the state folder or from .opencode/runs/ of --dir (default: the current directory). They then call the driver that the record names. No record means opencode. The drivers are opencode and claude. The claude driver has run, say, abort, and log so far: watch gives the error idfx cannot watch claude sessions yet and exit code 1. A record that names claude-glm gives the error idfx cannot drive claude-glm sessions yet and exit code 1. top and status read Claude Code sessions without a driver, from src/claude/; top and status list the Claude sandbox runs from their run records. A new CLI adds its name and one driver object to the registry.
bun run src/cli.ts attach CODE [--url URL]
Attaches the opencode TUI to a known run, like opencode attach URL --dir DIR --session ID. CODE is any part of the session ID that matches exactly one known run (case-sensitive substring). The known runs come from the run records of the state folder and of the current directory.
- No match:
error: no run matches "CODE", exit code 1. - Two or more matches: it lists the session ID, the title, and the directory of each match, tells you to give a longer part, and exits with code 1.
- One match: it starts
opencode attach URL --dir DIR --session IDwith the current terminal. The URL comes from--url, thenIDFX_URL, then the sandbox state of the directory, then the default. The command returns the exit code of the opencode process. - CODE may carry the agent icon of the
idfx topline (for example🔧3NcXxn): attach keeps only the letters, digits, and_of CODE before it matches.
While attach runs, it polls the server every 2 seconds. If the session is deleted, or if the server does not answer for about 6 seconds, attach ends the TUI. An idle session keeps the TUI open, so you can read the last screen and type a follow-up.
bun run src/cli.ts status [--dir DIR | --all] [--json]
One line per session: ID, state (busy, waiting, idle, or retry), title. A session with a pending question or permission request shows waiting instead of busy, because it makes no progress until it gets an answer. Without --all, it lists the sessions of the directory and of each of its git worktrees. A session of the directory itself has no suffix. A session of another worktree gets its folder at the end: relative to the directory when the worktree is inside it (for example .worktrees/x), else absolute. Child sessions (internal subagent runs) are not listed. If no server runs, it prints no server on <url> and exits with code 0.
With --all, it lists the running sessions of all projects, each as <id> <state> <title> (<absolute folder>). Idle sessions and child sessions are not listed. The folders come from the folders of past idfx run calls, from the projects that the server knows, and from their git worktrees. Folders that no longer exist are skipped. When no session runs, it prints no running sessions. --all and --dir together are a usage error.
With --json, stdout is one object of the tool protocol: {tool, version, time, source, sequence, conditions, items}. items holds the sessions, and conditions the True conditions of the Claude Code sessions, as idfx watch --all computes them. The fields are in docs/GUIDE.md, section "Check what runs".
A directory that fails to list does not stop the listing. It prints warning: <directory>: <message> to stderr, and the command continues with the next directory. This covers a project whose configuration references a missing key file.
bun run src/cli.ts top [--dir DIR | --all]
bun run src/cli.ts top --once [--dir DIR | --all] [--json]
A live view of the sessions, like htop. Without --all, it covers the directory of --dir (default: the current directory) and its git worktrees. With --all, it covers every directory of every known server (the host server and every sandbox). It shows the sessions that are not idle and the sessions with activity in the last 60 minutes.
One compact line per session, with one space between the columns: id (the agent icon, then the CODE for idfx attach CODE, the last 6 characters of the session ID; agents 🔧 coder, 🔎 researcher, 📖 reader, another agent shows its first two letters), where (the folder name under .worktrees/, or - for the main folder; with --all it is project/worktree, or only project for the main folder, and the project is the shortName from .opencode/idfx.json (old name .opencode/oc-sub.json) of the project root when the project has set one, else the full project name; a worktree name that starts with research- shows 🔬 instead of the prefix), ¢ (the cost in US cents, without a unit), run (elapsed time), last (time since the last event), stp (steps), tls (tool calls), ctx (context tokens), rsn (reasoning share), and title. The state has no column: the color of the id shows it, green busy, yellow waiting and retry, red stalled and looping, magenta reasoning, gray idle. --once colors the id only on a terminal. In a pipe it adds a state column with the word after id. The times have at most five characters: 42s, 4m05s, 34m, 3h12m, 2d04h. Seconds show only below ten minutes. The numbers align to the right. Icons are two cells wide, and the padding counts display cells. The cost and the tokens include the subagent sessions.
Without --once, it opens a full-screen view in the alternate screen. It follows GET /global/event of every server, reconnects after an error, and redraws on each change and once per second. j/k or the arrow keys select a session. A detail pane shows its pending requests, its subagent sessions as a tree, and its last 20 events. The footer shows the servers with their state, the totals, and the keys. o attaches to the selected session: inside tmux it splits the window and runs the attach in the new pane (side by side when the pane of top is wide, else below; tmux closes the pane when attach ends), without tmux it only shows the attach command. When the split fails, the footer shows the error and the attach command. a switches between the scope of --dir and --all, and q or Ctrl-C quit. The view has no keys that act on a session. When stdin or stdout is not a terminal, it prints the --once snapshot and a one-line hint to stderr.
With --once, it prints one text snapshot and exits: a header line, one line per session, and the pending requests indented below their session. --json prints the rows as JSON. It prints no sessions when nothing matches and no server on <url> when no server answers, both with exit code 0.
bun run src/cli.ts ping [--dir DIR]
Shows which OpenRouter key the opencode server uses for DIR, where the key comes from, and whether OpenRouter accepts it:
directory: /home/user/src/proj
project: proj
key: sha256 87ea509a
source: global auth.json /home/user/.local/share/opencode/auth.json
openrouter: ok, limit $1.00, used $0.00, remaining $1.00
The key: line shows the first 8 hex digits of the SHA-256 of the key. It never prints the key itself. source names the
10BC8
origin: the project key file ~/.config/<project>/openrouter.key, the environment variable OPENROUTER_API_KEY, or the global ~/.local/share/opencode/auth.json. The project name is the folder that holds the main repository, so a worktree counts as its repository.
The last line asks GET https://openrouter.ai/api/v1/key, which costs nothing. It shows the limit, the usage, and the remaining amount in USD. With no limit, it prints limit none and the usage. When the server uses another key than the project key file, ping prints a warning, because the cost then goes to another key. Exit code 0 when OpenRouter accepts the key, even with the warning. Exit code 1 when the provider is not configured for the directory, when no key is set, when OpenRouter rejects the key (openrouter: rejected (HTTP 401: ...)), or when the key endpoint is unreachable (openrouter: unreachable (...)).
The server caches the configuration. After a change of a configuration file, ping reports the old key until idfx restart.
ping --rules checks that the agent on the server really sees the shared rules:
bun run src/cli.ts ping --rules [--dir DIR]
It reads the first line that starts with # in <shared>/AGENTS.md on the host. Then it creates a session on the server of --dir (the normal URL resolution), sends one short prompt to the researcher agent with low reasoning effort, and asks it to reply with the first heading of its loaded instructions file, verbatim, or NONE. It prints rules: pass or rules: FAIL with the cost of the session, and it deletes the session afterwards when the API allows it. A failed deletion prints a warning and does not change the exit code. Exit code 0 on pass, 1 on fail. Run it once after idfx up.
The help document of idfx watch is {>41sHW68C} (mg get 41sHW68C): a graph of units that the pre-commit checks with mg commit-check.
bun run src/cli.ts watch SESSION [--dir DIR] [--json]
Follows the server's event stream and prints one short line per event of that session: tool calls with their main argument (tool bash: git status), failed tool calls (tool bash failed: ...), finished assistant texts (assistant: ...), and session errors. When the session and its subagent sessions become idle, it prints a summary line with the elapsed time, the number of tool calls, the cost in USD, and the tokens, then the real-cost line from OpenRouter (see log), and exits with code 0. The cost and the tokens cover the session and all of its subagent sessions (child sessions, recursively). With subagent sessions, the cost part reads cost $0.0816 (subagents $0.0665 in 4 sessions). Without subagent sessions, the line shows only the total.
When the session or one of its subagent sessions has a pending question or permission request, the run is paused. watch then prints one block per request with the request ID, the session ID, and the content, plus the exact idfx answer ... command, and exits with code 3. It detects the pause at the start, in every status poll, and on the question.asked and permission.asked events, so a request that was already pending is found too.
The guards tell the orchestrator early when a run goes wrong, without waiting for the end of the run. They cover the session and all of its subagent sessions, and they check three warning signs: a loop of five tool calls in a row with the same tool and the same input (the input is compared as JSON with sorted keys), a busy session with no event for 180 seconds, and one step with more than 16,000 reasoning tokens. On a finding, watch prints one block with the kind (loop, stall, or reasoning), the session ID, and the details, and exits with code 4. The run itself keeps running. The orchestrator reads the block, then aborts the run or sends a correction. The detectors are pure functions in src/detect.ts, so a later live view and a provider penalty can reuse them. Each finding is reported once.
The watch ends as idle only when the session and all its descendant sessions are idle or missing in the status map, and no request of the tree is pending. The status of a session can flip to idle for a moment between two requests, so watch checks the pending lists even when the status map says idle. Without a readable pending list it keeps watching.
It never misses the end of a run: it checks the status of the session and of all its subagent sessions when it starts, after every reconnect of the event stream, and every two seconds as a safety net. The final summary is computed from the messages of the session tree, not from the watched events. The server lists only sessions that are not idle in GET /session/status. A session that is missing from that map has either ended, or it was started a moment ago and the server has not marked it busy yet. So watch reads the messages of a missing main session. If the last message is a finished assistant message, the session has ended, and the watch ends at once. Otherwise the watch ends only when the session was quiet for 10 seconds (no update and no new message). This closes the race when watch starts right after run. A missing subagent session counts as ended. With --json, it prints the filtered events as JSON lines instead, and the summary and the request blocks go to stderr.
bun run src/cli.ts answer REQUEST_ID [--dir DIR] (--reply once|always|reject [--message TEXT] | --reject | ANSWER...)
Answers a pending question or permission request of the run in DIR. The command looks the request ID up in the two pending lists of the server (GET /question and GET /permission) to learn its kind. If the ID is in neither list, it stops with an error.
For a question, pass one positional ANSWER per question, in order. The answer is the label of an option or free text. --reject rejects the question, and the tool call of the agent fails with a clear message. For a permission request, --reply is required: once allows the tool call one time, always allows it for the rest of the session, and reject refuses it. With --reply reject, --message TEXT gives the agent the reason. The agent sees the message as the error of the tool call.
A rejected permission request ends the turn of the agent. After such a rejection, the command prints a hint to send a follow-up message with idfx say. --message is only allowed with --reply reject.
An unknown ID, a wrong kind (for example --reply on a question), and an answer count that does not match the questions stop with an error before anything is sent. After the answer, start watch again to follow the rest of the run.
bun run src/cli.ts say SESSION [--dir DIR] [--agent NAME] TEXT
Sends TEXT as a follow-up message into the session and returns at once. It uses prompt_async, so it does not wait for the reply to end. Without --agent, it takes the agent from the last user message of the session. A session without a user message needs --agent NAME. It prints one line:
sent to ses_abc123 (agent coder). Watch it with: idfx watch ses_abc123 --dir /path/to/worktree
bun run src/cli.ts log SESSION [--dir DIR]
Prints the final assistant text of the session, one summary line with the cost and the token totals (input, output, reasoning, cache read, cache write), and one real-cost line. The totals cover the session and all of its subagent sessions (child sessions, recursively). With subagent sessions, the cost part reads cost $0.0816 (subagents $0.0665 in 4 sessions).
The real-cost line is the real charge at OpenRouter, not the estimate of opencode. run stores the key usage at the start in the run record, and log reads the usage now. The line shows the difference: real cost $0.0512 at OpenRouter (key usage since the start of the run). The real cost is only exact when no other run used the project key during the run. Other runs with the same key that overlap in time add their cost to the same number, so the line names them: , includes other runs: ses_a, ses_b. OpenRouter counts a request a minute or two late, so a log some minutes later can show a slightly higher real cost. Without a run record or without the usage at the start, the line reads real cost: unknown (no key usage at the start of the run).
echo '{"state":"The sky is blue today.","question":"What colour is the sky?","options":{"blue":"The sky is blue.","red":"The sky is red."},"title":"my-project"}' | idfx decide --json
Asks the pinned Jev model one choice question through the OpenRouter decisions endpoint. Another project uses it, so that it needs no model client and no key of its own. --json is required.
The input is one JSON object on stdin:
state: an object or a string. As JSON, it has at most 4000 characters. A longer state is an input error;decidedoes not cut it.question: the instructions of the question.options: an object from the option name to its criterion text, with at least 2 options.title(optional): theX-Titleheader of the request, so the OpenRouter activity shows the caller.
On success, it prints one JSON line on stdout and exits 0: choice, confidence, probabilities, model, cost (USD), and id. A missing value is null. On a failure, it prints {"error": {"type": ..., "message": ...}} on stderr. The type is limit for HTTP 402 or 429, auth for HTTP 401 or 403 or a missing key, input for a bad stdin (exit 2), and failed for all other failures (exit 1). A 429 or 5xx gets one retry after two seconds. Stop on limit and auth; do not try another service.
The key is OPENROUTER_API_KEY, else the key file of the project idfix (~/.config/idfix/openrouter.key), not the key of the folder of the caller. Each call that reached the API appends one JSON line to decide.log in the state folder ($XDG_STATE_HOME/idfx/): the time, the HTTP status, the model, the cost, the ID, the title, the choice, and the error type.
bun run src/cli.ts abort SESSION [--dir DIR]
Aborts the session (POST /session/:id/abort). For a Claude run, see "Claude Code runs: run --driver claude".
bun run src/cli.ts doctor [--dir DIR] [--json]
bun run src/cli.ts doctor --fix [--force] [--dir DIR] [--json]
bun run src/cli.ts doctor --renovate [--dir DIR] [--json]
bun run src/cli.ts doctor --fix-as-root [--force] [--dir DIR] [--json]
Runs the health checks of the project of --dir (default: the current folder) and of the host, prints one line per check (status, name, message, and the fix on the next line), and ends with a summary line. --json prints one object of the tool protocol, {tool, version, status, checks}, as the whole stdout. This is the doctor format of the shared tool protocol. Each check has name, status, message, a fix string (empty when the check has no hint), and a stable type urn:dv:idfx:doctor:<name>. A check that throws gets the status error. The top status is fail when a check fails or has the status error, else warn when a check warns, else pass. Exit code 0 when the doctor ran, also when a check fails. Read the JSON status for the result. Exit code 2 for a usage error or when the doctor itself cannot run. The task mise run -q doctor -- --json runs the doctor of a checkout. The slow checks (a git call, one mise current opencode call, and the sbx calls) run only here.
With --fix, the command first runs the checks, then the fix action of every check in the registry order whose result is warn or fail and that has a fix action. It prints fixing <name>: <fix text> before each action and fixed <name>: <note> or fix failed (<name>): <note> after it. A failing action does not stop the other actions. Then it runs all checks again and prints their results. With --json, the fix lines go to stderr, and stdout holds the same object with fixes. The exit code is still 0 when the re-run has a fail or when a fix action failed. The JSON status and the fixes list say so. --fix never prompts and never calls sudo. --force is only valid together with --fix, --renovate, or --fix-as-root. Some fixes end sessions or processes, or remove content, so they run only with --force: agent-copies, sandbox-mounts, top-memory, orphan-processes, and units. Without --force, such a fix changes nothing, counts as a failed fix, and its note names the flag. The guards inside a fix still block with --force. --renovate lifts the project to the current standard: it implies --fix and --force. --fix-as-root implies --fix and also runs the root fixes, which call sudo (today only kvm-access). In a terminal, sudo can ask for the password. Without a terminal, it runs sudo -n. Without --fix-as-root, a root fix does not run, and the line needs --fix-as-root (<name>): ... names the flag. With --fix --json, the object has fixes ([{name, ok, note}]), and checks holds the re-run results.
Which checks have a fix action:
global-rules: for each of the three rule paths, a copy whose content equals the sharedAGENTS.mdexactly becomes a symlink to it; a copy with different content is left alone (the fix fails and names it), so no edit is lost. A broken or wrong symlink is re-pointed. A missing path is not created. Without the shared file, the fix fails and changes nothing.agent-copies: needs--force, because it removes content. It checks each project agent file that is not permission-only. It keeps only thepermissionblock of the front matter. It drops the description, model, prompt, and other keys. It deletes a file without apermissionblock. Each file must be clean in git (tracked and unmodified), so git holds the old content. The fix does not touch a file that is not clean, and its note names the file, its state, and the step by hand.state-names: moves the old state folder$XDG_STATE_HOME/oc-sub/into$XDG_STATE_HOME/idfx/. It stops when aserve-<port>.lockexists in the old folder, because then a run starts or the watchdog stops a server. It moves each entry with a rename, so a running server keeps writing its log. An entry whose name exists in both folders stays, and the fix fails and names it. When the old folder is empty, the fix removes it and links the old path to the new folder.project-config-name: renames.opencode/oc-sub.jsonof the project to.opencode/idfx.json. It never overwrites a new file. Commit the rename yourself.opencode-version: when the deciding pin is in the projectmise.toml, it sets that pin to the tested version. It keeps the rest of the file and runsmise installin the project root. The file must be clean in git, else nothing changes. When the deciding pin is in the global mise configuration, nothing changes, because that file belongs to the user. Then the note names the line to set by hand. It needs no--force, because git holds the old file.plugin-fresh: runsclaude plugin marketplace update idfixand, when that exited 0,claude plugin update idfix@idfix. A non-zero exit is a failed fix. When only the old keyopencode-subagents@opencode-subagentsis installed, the check warns and names the reinstall commands, and the fix runs nothing, because the reinstall changes the plugin configuration of the user.server-plugin: syncs the plugin folder of the servers from the plugin of this idfx, then restarts each running server that started with other plugin content. When all sessions of a server are idle, it restarts the server. A busy server stays as it is, and the fix fails with a note that namesidfx abortandidfx down. It needs no--force, because an idle server loses no work.kvm-access: a root fix. Only--fix-as-rootruns it. It runssudo chmod 0666 /dev/kvm(sudo -nwithout a terminal). The mode lasts until WSL creates/dev/kvmagain at the next WSL restart. A permanent fix is a task of the machine setup.sandbox-mounts: needs--force, because it ends all sessions of the sandbox. It recreates the sandbox withsbx rm --force NAMEandidfx up. Two guards always block, also with--force: a busy session on the sandbox server, and unfetched or uncommitted work in the clone. When the sandbox does not start, a recreate does not help, and the note namessbx diagnose.host-proxy: copiescontrib/systemd/idfx-proxy.serviceto~/.config/systemd/user/idfx-proxy.service(or$XDG_CONFIG_HOME/systemd/user/) when the copy is missing or differs, then runssystemctl --user daemon-reloadandsystemctl --user enable idfx-proxy.service. Then it runsrestartwhen the file changed or the unit is active, elsestart. It probesHEAD http://127.0.0.1:4090/api/helloup to 10 times, 500 ms apart. The fix is ok only when the proxy answers; else the note names the log. When another tool manages the user units, the fix changes nothing and runs nosystemctlcommand. It counts as a failed fix, and its note names that tool (see the checkhost-proxy).top-memory: needs--force, because it ends a view of the user. It scans the processes again and sends SIGTERM to eachidfx topprocess over 1 GiB, never to doctor itself.orphan-processes: needs--force, because it ends processes. It sends SIGTERM to each orphaned process and to all its descendants of the current user. After 5 seconds, it sends SIGKILL to each process that still runs.units: needs--force, because it stops processes. It lists the units again and stops each orphaned unit withsystemctl --user stop, never the unit of doctor itself. A unit that is no longer loaded counts as done. When a stop fails, the fix fails.
The checks:
check: Check
what-it-checks: What it checks
fail-means: Fail means
--
check: `env-files`
what-it-checks: No real `.env` or `.env.*` file in the project root or in any folder of `.worktrees/`, except names that end in `.example` or `.sample`. It never opens the file.
fail-means: A key file sits in the project. Move the keys to `~/.config/<project>/<provider>.key` and delete the file.
--
check: `claude-md`
what-it-checks: No `CLAUDE.md` or `CLAUDE.local.md` in the project root.
fail-means: Claude Code would read the wrong rules file. Rename it to `AGENTS.md`.
--
check: `agents-md`
what-it-checks: The project root has `AGENTS.md`.
fail-means: Warn only. The agent misses the rules of the project.
--
check: `global-rules`
what-it-checks: `~/.claude/CLAUDE.md`, `~/.config/opencode/AGENTS.md`, and `~/.codex/AGENTS.md` are symlinks to `<shared>/AGENTS.md`.
fail-means: A copy drifts from the source, or a link is broken. Missing paths are a warn, because the tool may not be installed. `--fix` replaces an equal copy or a broken link with a symlink; a copy with different content is not changed.
--
check: `skill-links`
what-it-checks: Every symlink in `~/.claude/skills/` and `~/.agents/skills/` resolves to an existing folder.
fail-means: A skill is gone. Remove the broken link or point it back.
--
check: `agent-copies`
what-it-checks: `.opencode/agents/coder.md`, `researcher.md`, and `reader.md` are permission-only files or absent (see `.plan/research/agent-merge.md`).
fail-means: A project copy overrides the plugin agent. Delete it, or keep only a permission block. `--fix --force` keeps only the permission block.
--
check: `state-names`
what-it-checks: The old state folder `$XDG_STATE_HOME/oc-sub/` is missing or is a link. While it is a real folder, idfx keeps its state there.
fail-means: Warn. `--fix` moves the old folder into `$XDG_STATE_HOME/idfx/` and links the old path to it.
--
check: `project-config-name`
what-it-checks: The project root has no old config file `.opencode/oc-sub.json`.
fail-means: Warn. `--fix` renames it to `.opencode/idfx.json`. When both files exist, merge them by hand.
--
check: `opencode-version`
what-it-checks: The opencode version that `mise current opencode` resolves in the project root equals the `opencode` pin in the `mise.toml` of idfx, the tested version, and the pin that decides it (the project `mise.toml`, else the global mise configuration) is that exact version. A pin such as `"latest"` warns even when it resolves to the tested version today, because the next release changes it.
fail-means: Warn. Set the tested version in the project `mise.toml` (or in the global mise configuration when the project has no pin) and run `mise install`. When the pin is in the project `mise.toml`, `--fix` sets it.
--
check: `opencode-release`
what-it-checks: The latest opencode release (`mise latest opencode`) is not newer than the tested version, or not newer than the reviewed version in `opencode-review.json` of the idfx repository. It reminds you to review a new release from time to time. A failed or empty `mise latest` call (no network) skips the check, and so does a missing tested pin.
fail-means: Warn. Read the release notes of the new version, then either raise the pin in the `mise.toml` of idfx and run the tests, or record the decision in `opencode-review.json`. No `--fix` action.
--
check: `plugin-fresh`
what-it-checks: The installed plugin commit matches `origin/alpha` of the plugin repository.
fail-means: Warn. `--fix` runs the plugin update commands that the fix names.
--
check: `server-plugin`
what-it-checks: Every server loads the synced plugin folder. That folder equals the plugin folder of this idfx, and each running server started with the content that the folder holds now. A server without a plugin record started with an older idfx and counts as stale. Without a running server, a missing synced folder passes, because the next `up` creates it. Without the plugin folder, it skips.
fail-means: Warn. The plugin changed since the last `up`, or a server runs old plugin content. `--fix` syncs the folder and restarts each idle server. A busy server needs `idfx abort` or `idfx down` first.
--
check: `kvm-access`
what-it-checks: The current user can read and write `/dev/kvm`. `idfx up` in sandbox mode runs the same check before its first `sbx` call. Off Linux, it skips.
fail-means: `sbx` cannot start a sandbox. When `/dev/kvm` is missing, turn on KVM (on WSL: `nestedVirtualization=true` in `.wslconfig`) and restart. When the mode blocks the user, `--fix-as-root` runs `sudo chmod 0666 /dev/kvm`.
--
check: `sandbox-mounts`
what-it-checks: When a sandbox state file exists, `sbx ls` lists all mounts that `up` requires (a folder inside the project root is not mounted, the clone holds it), the project has the `sandbox-<name>` git remote of clone mode, and the clone exists inside the sandbox (`git -C <root> rev-parse --git-dir`).
fail-means: Run `sbx rm --force NAME` and then `idfx up`, which creates the sandbox again in clone mode. When no session is busy and the clone holds no unfetched work, `--fix --force` runs these two steps.
--
check: `deepinfra-key`
what-it-checks: The optional DeepInfra key file `~/.config/<project>/deepinfra.key` has mode 600 or stricter. It only reads the mode, never the content. Without the file, it skips (DeepInfra is off).
fail-means: Warn only. Other users may read the key. Run `chmod 600` on the file.
--
check: `research-due`
what-it-checks: No research report in `<plan_dir>/research/` of the project has a due recheck head (`checked`, `recheck`, `decisions`). The plan folder is `plan_dir` of `.handover.toml`, else `docs`. A report with a due date of today or earlier is due. A trigger such as `on ...` is never due by date. Reports without a head do not count.
fail-means: Warn only. The message names each due report, its due date, and its decisions, and each report with an invalid head. Recheck the facts with a researcher run, then set `checked` to today. A bad `plan_dir` also warns. No `--fix` action.
--
check: `watch-running`
what-it-checks: The holder of the lock `events.lock` of `idfx watch --all` lives: its PID exists and its start time matches.
fail-means: Warn. No watcher runs, so the supervisor gets no wake-up. Link `contrib/systemd/idfx-watch.service` into `~/.config/systemd/user/` and run `systemctl --user enable --now idfx-watch.service`. No `--fix` action, because the user installs the unit.
--
check: `host-proxy`
what-it-checks: The host cost proxy runs as the systemd user service `idfx-proxy.service`: the installed unit file equals the shipped `contrib/systemd/idfx-proxy.service`, and `systemctl --user show` gives `UnitFileState` `enabled` (or `enabled-runtime`) and `ActiveState` `active`. Without a user manager, it skips.
fail-means: Warn. The unit is not installed, is outdated, is not enabled, or is not active (the message names the log `proxy-host.log` and `journalctl --user -u idfx-proxy`). `--fix` installs, enables, and starts the unit, and probes it. When `idfx-proxy.service` or `idfx-watch.service` in the user unit folder is a symbolic link, another tool manages the user units. Then the check also warns on a plain copy, and its hint names that tool or `systemctl --user enable --now idfx-proxy.service`. `--fix` changes nothing then.
--
check: `top-memory`
what-it-checks: No `idfx top` process of the current user uses more than 1 GiB of RSS. A `top` that leaked keeps its whole table in memory. Without `/proc`, it skips.
fail-means: Warn. The message names the PID and the RSS in MB of each process. `--fix --force` sends SIGTERM to each listed process, never to doctor itself.
--
check: `orphan-processes`
what-it-checks: No process of the current user runs in a deleted folder with PID 1 or `/init` as its parent. Without `/proc`, it skips.
fail-means: Warn. The message lists at most 10 processes with PID, command, and folder. `--fix --force` sends SIGTERM to each process and its descendants, then SIGKILL after 5 seconds.
--
check: `units`
what-it-checks: Lists each loaded systemd user unit of idfx (`idfx-*`, and `ocsub-*` of older versions) with its owner and its reason (at most 10 entries and the total count). A unit is orphaned when its working folder is gone, or when it is a `proxy` or `idle` unit of a port without a `serve` or `holder` unit. It does not ask whether a named owner session still lives. Without a user manager, it skips.
fail-means: Warn. An orphaned unit runs for no one. `--fix --force` stops each orphaned unit, never the unit of doctor itself.
The fast checks env-files to agent-copies also run on every idfx up and idfx run. A fail stops the command with exit code 1 before anything changes state and before any paid call, and names the fixes plus the hint run idfx doctor for details. A warn prints one line and the command continues. The checks take about 1 ms. When they take over 50 ms, the command prints a warning with the time.
bun run src/cli.ts worktree STEP [--dir ROOT] [--base BRANCH]
bun run src/cli.ts worktree rm STEP [--dir ROOT]
Sandbox clone mode only. worktree STEP creates the worktree of a run inside the sandbox clone at <root>/.worktrees/STEP. It points the clone remote host to the read-only host repository /run/sandbox/source, fetches host (never origin, which the sandbox may not reach), copies the git identity of the host repository into the clone, and creates feature/STEP from host/alpha (--base names another branch). When the worktree exists, it says so and exits 0. In both cases it then disposes the cached opencode instance of the folder (POST /instance/dispose). opencode keeps one instance per directory, and a run that reached the folder before it existed leaves a broken instance that fails every later prompt there. A failed dispose is only a warning. worktree rm STEP removes the worktree and deletes feature/STEP inside the clone. Work that was not fetched is lost. Both commands exit 1 without a sandbox state file for the project.
bun run src/cli.ts fetch [--dir ROOT]
Sandbox clone mode only. Runs git fetch sandbox-<name> on the host and prints every fetched feature/* branch with its commit count over alpha, plus the review and merge commands. Exit 1 without a sandbox state file.
sbx stop removes the remote sandbox-<name> from the host repository, and the next start of the sandbox adds it again. So fetch fails while the sandbox is stopped, for example after an idle stop. Then fetch prints the hint the sandbox <name> is stopped. Start it with idfx up, then fetch again.
bun run src/cli.ts proxy [--port 4090] [--hostname 127.0.0.1] [--log FILE] [--upstream URL] [--deepinfra-upstream URL]
Runs the cost proxy (see "Cost proxy" in docs/GUIDE.md) in the foreground until SIGTERM or SIGINT, then exits with code 0. It listens on 127.0.0.1:4090 by default. At the start it appends a start marker line to the log, then one JSON line per request. The default log is $XDG_STATE_HOME/idfx/proxy-host.log (default ~/.local/state/idfx/proxy-host.log). It also prints the listening line to stdout, so the journal of the unit shows it. On SIGTERM it stops the server and lets open requests finish, so their end lines with the cost reach the log.
This is the host proxy: one proxy per user, as the systemd user service idfx-proxy.service. A Claude Code session on the host points ANTHROPIC_BASE_URL at http://127.0.0.1:4090. idfix ships the unit file contrib/systemd/idfx-proxy.service. It runs %h/.local/bin/idfx proxy --port 4090, restarts it 5 seconds after a failure, and starts it with the session of the user. It has no Slice= line, so it stays out of idfx.slice, and the units check does not list it. idfx doctor --fix installs, enables, and starts it (check host-proxy). The fix overwrites a copy that differs from the shipped file, so put local changes into a drop-in, for example ~/.config/systemd/user/idfx-proxy.service.d/local.conf.
A configuration manager, for example chezmoi, can own the user units instead. It links contrib/systemd/idfx-proxy.service of the idfix checkout into the user unit folder. idfx doctor sees such a tool when idfx-proxy.service or idfx-watch.service in that folder is a symbolic link. Then idfx doctor only reports. It never writes the unit file and never runs systemctl. Install the link with that tool, then run systemctl --user enable --now idfx-proxy.service. A tool that installs plain copies, not links, is not detected, and no setting can declare it yet.
The proxy of idfx up in host mode (port of the server plus one) is a separate process and stays as it is.
bun run src/cli.ts up --port 8767
bun run src/cli.ts run --agent researcher --dir <repo> --brief brief.md --title "Research X" | head -1
bun run src/cli.ts watch <session-id> --dir <repo>
bun run src/cli.ts log <session-id> --dir <repo>
bun test runs the unit tests in test/ (argument parsing, event filtering and line formatting, cost and token summary, the end check of a session missing from the status map, the child sessions of a session and their usage, run records, state files, the process check of down, client helpers, the pending question and permission requests, and the pause detection of watch against a fake server) and integration tests. The integration tests start a real opencode serve on a free port from 8790 upward. up also binds the next port for the cost proxy. So each test reserves the pair of ports with a lock file in a folder under the system temporary folder that all test runs share, and two test runs at the same time never clash. The tests run up, create sessions over the SDK without sending any prompt, check status, run abort, check the pending lists and answer against a server without pending requests, and stop the server with restart and down. They never call a model and cost nothing. They start their units with IDFX_OWNER=test. The teardown of each test fails when a unit of its port or a process of its PID files is left. After the last test file, the test preload stops each owner=test unit on a test port that this run or a killed run left. They skip themselves with a clear message when the command opencode is not on the PATH.
The preload test/setup.ts gives each test run one temporary folder, oc-sub-test-run-* in the system temp folder. It points TMPDIR and the XDG data and state folders at it, and a global afterAll hook removes it after the last test. So a test can create temporary folders with mkdtempSync(tmpdir()) and leaves nothing in /tmp. The preload also removes run folders older than six hours, which a killed run left behind. test/temp-hygiene.test.ts makes sure that the redirect is active.
A git hook sets repository-local git variables such as GIT_DIR and GIT_INDEX_FILE. A git command in a temporary folder would then act on the idfix repository. So the preload removes every variable that git rev-parse --local-env-vars names. Bun 1.4 has a trap here: Bun.spawn and Bun.spawnSync without an env option pass the environment of the process start, not the current process.env. So the preload wraps both, and a call without env passes process.env. test/git-env.test.ts checks this. To prove it, run GIT_DIR=$PWD/.git GIT_INDEX_FILE=$PWD/.git/index mise run test and check that git status does not change.
No test may cause inference costs. So the preload also guards each test and each child of a test:
- A fake
claudeandclaude-glmcome first on the PATH. They printidfx test guard: ...on stderr and exit with code 97. The fakeopencoderefusesopencode runthe same way and runs the real opencode for every other command. - The preload drops each key variable, for example
ANTHROPIC_API_KEY,CLAUDE_CODE_OAUTH_TOKEN,OPENROUTER_API_KEY, and each other name that ends in_API_KEY,_TOKEN,_SECRET, or_ACCESS_KEY. HOME, the XDG folders, andCLAUDE_CONFIG_DIRpoint into the run folder. So no test reads the real login or a key file. git gets a test identity fromGIT_CONFIG_GLOBAL. The shared bun install cache stays, so no npm package downloads again.- A
fetchof the test process to a model provider throws.
test/inference-guard.test.ts checks the guard. test/no-inference.test.ts reads each test file and fails on a model provider host or a command that starts a model CLI. A file may name a host only as data that a fake records, and its entry in the allow list names the reason. A test that must call a model is a live test: it uses liveTest or liveDescribe of the preload and runs only with IDFX_LIVE=1 bun test <file>. The push gate never sets IDFX_LIVE. The guard does not block the network of a child process.
src/cli.ts— entry point and command dispatchsrc/help/— the help documents, one per command, of the kind helpsrc/args.ts— argument parsing (pure)src/config.ts— server URL and basic-auth resolution (pure)src/client.ts— SDK client, health check, result handlingsrc/summary.ts— cost/token accounting and formatting (pure)src/events.ts— event filtering and watch lines (pure)src/detect.ts— the guards ofwatch: loop, stall, and reasoning detectors (pure)src/tree.ts— the descendant sessions of a session, their messages, and their costsrc/requests.ts— pending questions and permissions: list, filter, format, answersrc/keys.ts— OpenRouter key handling: fingerprint, key sources, key check, shared-key refusal; the DeepInfra key path and placeholdersrc/runs.ts— run records in.opencode/runs/and in the state folder, real-cost linesrc/driver.ts: the driver registry with theopencodeand theclaudedriver, whichrun,say,abort,watch, andloggo throughsrc/claude/run.ts:run --driver claude, one blocking Claude Code run in the Claude sandbox of a project, and its run recordsrc/claude/session.ts:say,abort, andlogfor a Claude sandbox runsrc/claude/sandbox-state.ts: the state folder of a Claude sandbox, the sync of the host configuration, and thesbx createandsbx execcommandssrc/realcost.ts— the real-cost output ofwatchandlogsrc/settled.ts— decides whether a session missing from the status map has ended (pure)src/units.ts: the start and the stop of theidfx-*systemd user units (and of the oldocsub-*units), with the fallback to a detached process (src/spawn.ts)src/host-proxy.ts: the host cost proxy: theproxycommand, the path of its unit file, and the/api/helloprobesrc/state.ts: per-user state files of the server (PID, log, folders with runs, lock), and the move of the old state foldersrc/env-names.ts: the environment variablesIDFX_*src/lock.ts: the server lockserve-<port>.lockofrunand the idle watchdogsrc/idle.ts: the idle watchdog of a server: the pure busy tracker, the hiddenidle-watchcommand, and its start and stopsrc/attach.ts— theattachcommandsrc/doctor.ts— the health checks, the fast gate forupandrun, and thedoctorcommandsrc/top/—idfx top:model.ts(the pure session model),load.ts(the REST seed and--once),live.ts(the event streams),columns.tsandformat.ts(the columns and the text table, pure),view-model.ts(the pure view logic),view.tsxandapp.tsx(the Ink view)src/up.ts,src/down.ts,src/down-all.ts,src/run.ts,src/status.ts,src/ping.ts,src/watch.ts,src/log.ts,src/abort.ts,src/answer.ts— the commands
MIT. See LICENSE.