← Catalog

@instruction.md/agents

Make Claude Code, Codex and other coding agents follow an instruction from instruction.md, and get each new version as it is released. The instruction-agents CLI: hooks for 14 agents, an ACP proxy, a pi extension and an SDK helper; run, an…

Package

Install

Install with PiG

pig install npm:@instruction.md/agents

Install with Pi

pi install npm:@instruction.md/agents
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./dist/pi.js"
  ]
}

README

Written by the package's publisher, shown as published in version 0.4.3 (README.md). PiG does not review it.

@instruction.md/agents

The agent side of instruction.md. It is a command-line tool, instruction-agents, plus two small modules. Together they make Claude Code, Codex and other coding agents follow a released instruction, and they run one agent for each instruction you deploy. Beta (0.x), MIT licensed, Node.js 18 or later.

npm: @instruction.md/agents · Docs · Issues · Versions · License: MIT

At a glance

  • What it is. On instruction.md, people write instructions: Markdown documents whose MUST, SHOULD and NEVER rules bind an AI agent. They release versions, and agents follow them over MCP. This package is what runs on the agent's machine. It gives each agent the version it should follow. When a new version is released, the agent gets it at its next turn.
  • The problem it solves. The usual way is to paste a prompt into CLAUDE.md or AGENTS.md in every repository, and it goes stale. This package lets a project name one instruction instead. Every session starts with the released text. A running session gets each new version. The signature is checked if you ask for it. Each session's version is reported back, so you can see who runs what.
  • What it does.
    • Following an instruction. Hooks for Claude Code, Codex and twelve other coding agents. An ACP proxy for Zed, JetBrains and any ACP client. An extension for pi and a plugin command for Amp. follow() for an agent you build with an SDK.
    • Running agents. run starts one agent per deployment of an instruction, each in its own folder. When an agent asks a question or needs a permission, you answer it on instruction.md/agents. You can also write to an agent or stop it from there. With --remote-control you control each agent in the Claude app instead.
    • Servers, skills and sign-ins. apply writes the MCP servers and skills that an instruction names into Claude Code's or Codex's own settings. accounts, signin and credential supply each server's credential on this machine. check tells you what would stop an agent.
  • Who it is for.
    • Developers who want Claude Code or Codex in a project to follow a team's instruction.
    • Platform teams who run agents unattended, on a laptop, a server or in CI.
    • Administrators who put one instruction on every developer machine through managed settings.
  • Where it fits. The instruction.md package provides the instruction command. You use it to write, check and release instructions, and this package is built on it. The server is instruction.md's MCP endpoint, https://instruction.md/mcp (MCP 2026-07-28, stateless).
  • Status. Beta, version 0.x. The package first shipped on its own in November 2026. Before that, these commands were part of the instruction.md package, up to its 0.9.0. Hooks for Claude Code and Codex are the most used and tested. Some parts are newer:
    • The Amp plugin has not been run inside Amp itself.
    • Kiro and Junie are set up by hand.
    • --remote-control works on Linux and macOS only.
    • Sealed (end-to-end encrypted) instructions and conversations use instruction.md's seal library. That library has not had an independent cryptographic review yet.
  • License. MIT. You may use, change and redistribute it in open or closed software, commercially or not. Keep the copyright and license notice. Its dependency, the instruction.md package, carries data from the instruction.md specification under CC BY 4.0 (the registry and schemas) and Apache-2.0 (the conformance vectors), and eleven Lucide icons (ISC). NOTICE describes that material and where it comes from.
  • Cost. Reading an instruction is never limited, on any plan. The hooks only read, so they never use the Community plan's one live connection. Deployment rules (run --rule) need a Team or Enterprise plan. Deploying a single instruction (run --platform) needs Pro or above.
  • Support. For questions and bugs, use GitHub issues. For anything else, use Contact us.

Install

Pick one of these ways to install:

npm install -g @instruction.md/agents     # the instruction-agents command
pnpm add -g @instruction.md/agents
npx -y @instruction.md/agents <command>   # without installing (what generated hook settings use)

If the instruction command (npm install -g instruction.md) is installed, every command here also runs as instruction agents <command>. It runs instruction-agents if that is installed, and otherwise npx --yes @instruction.md/agents. The docs use that form. All three forms run the same code:

instruction-agents run --platform laptop -- claude -p "Work through today's queue."
instruction agents run --platform laptop -- claude -p "Work through today's queue."
npx -y @instruction.md/agents run --platform laptop -- claude -p "Work through today's queue."

As a library (for follow() or pi's SDK):

npm install @instruction.md/agents

As a pi package:

pi install npm:@instruction.md/agents     # or, for one run: pi -e npm:@instruction.md/agents

Requirements

  • Node.js 18 or later.
  • The agent's own app for the agents you use, such as Claude Code or Codex. This package doesn't install it.
  • An instruction.md sign-in for private instructions, for reporting versions, and for run, apply and check. Run instruction-agents login (--device on a machine with no browser), or set INSTRUCTION_MD_TOKEN. The hooks, pi and the ACP proxy follow a public instruction without signing in.
  • A token for follow() (the SDK helper), even for a public instruction: it reads over MCP, and the MCP server answers only a signed-in caller. It doesn't use the stored login. See Follow an instruction in your own agent.
  • --remote-control needs Linux or macOS (it uses the system's script command for a terminal) and a claude.ai sign-in in Claude Code (Pro, Max, Team or Enterprise). An API key won't work.
  • Plans for run: see Cost.

Quickstart

This makes Claude Code follow an instruction in one project. It takes about two minutes and needs no account, because the example instruction is public.

mkdir try-instruction && cd try-instruction

# 1. The project follows a public example instruction (a code reviewer's rules): writes
#    .instruction/follow.json, .instruction/.gitignore and two hooks in .claude/settings.json
#    (merged into what is there)
npx -y @instruction.md/agents follow instruction-md/code-review --host claude-code --write

# 2. See what a session is given at its start (this is what Claude Code's SessionStart hook runs)
echo '{"session_id":"s1","hook_event_name":"SessionStart","source":"startup"}' \
  | npx -y @instruction.md/agents hook claude-code

# 3. At a prompt, while the version is unchanged, the hook prints nothing at all
echo '{"session_id":"s1","hook_event_name":"UserPromptSubmit"}' \
  | npx -y @instruction.md/agents hook claude-code

Step 1 ends with two extra lines: claude mcp add instruction-md … and a sentence to say in a session. They are another way to reach instruction.md, through its MCP server, and you don't need them for this Quickstart: the hooks already give every session the instruction.

Step 2 prints one JSON object, which Claude Code adds to the session (shortened here):

{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"These are this project's instructions from instruction.md (instruction-md/code-review v2). Follow them.\n<instruction uri=\"instruction://instruction-md/code-review\" version=\"v2\" digest=\"sha256:…\">\n# Code review\n\nYou review pull requests for this team. …\n\n## Rules\n\nMUST: read the whole change and the code it touches before commenting.\n…\n</instruction>"}}

Now run claude in the folder. It asks once whether to trust the project's hooks. After that, every session starts with the instruction.

For your own instruction, sign in first. Then name the instruction as owner/name@ref:

npx -y @instruction.md/agents login
npx -y @instruction.md/agents follow acme/support@stable --host claude-code --write   # or --host codex

Commit .instruction/follow.json and the hook file, so everyone who works on the project follows the same instruction. Without --write, the command prints the files instead of writing them.

How it works

  • A project names what it follows. .instruction/follow.json holds an address such as instruction://acme/support@stable. A ref (@stable, @latest) moves when someone releases a new version. A version (@v3) never moves.
  • The agent's app runs a hook. At a session's start, the hook gives the whole delivered text (the exact text a model receives). At each later prompt it checks the version. If the version is unchanged, it adds nothing. After a release, it adds the new version, marked as replacing the earlier one in full, and shows the person one line.
  • It never holds a prompt up. The hook reads at most every refreshSeconds (60 by default) and waits at most 1.5 s. When a read fails or is slow, it uses the last good copy (.instruction/current.md). It always exits 0. With --fail-closed, it still exits 0, and blocks through its answer instead.
  • It reads and never subscribes. When you are signed in, it reads over MCP and reports which version each session applied, and in which app. Without a sign-in, it reads a public instruction over plain HTTP, with a conditional request.
  • Policy is checked on the machine. With requireSignature, a version whose author signature doesn't verify is held, and the last good version stays. Signed in, the hook checks it against the publisher's keys from instruction.md. Without a sign-in, it needs the keys in a file (keys in follow.json). A held version is reported once. A sealed instruction is opened with the machine's key, or held with the reason. The agent's context never receives ciphertext.

Usage

Make a project's agent follow an instruction (Claude Code and Codex)

instruction-agents follow acme/support@stable --host claude-code --write   # .claude/settings.json
instruction-agents follow acme/support@stable --host codex --write         # .codex/hooks.json

It writes these files, merged into what is already there. It never overwrites a file it can't read:

  • .instruction/follow.json, which you commit: { "follow": "instruction://acme/support@stable" }. You can add the other keys yourself.
  • .instruction/.gitignore, which keeps current.md, state.json and given/ (the fetched text and its state) out of the repository.
  • The hooks. Each one runs npx -y @instruction.md/agents hook claude-code (or codex):
    • Claude Code: SessionStart (timeout 10 s) and UserPromptSubmit (timeout 5 s).
    • Codex: the same two hooks, with additionalContextLimit: 0 so that Codex doesn't cut the text.

For Claude Code and Codex, --write also adds "apply": ["claude-code"] (or "codex") to follow.json. If you are signed in, it then writes the instruction's MCP servers and skills right away (see Servers, skills and sign-ins). Use --no-apply to skip both. Add --require-signature to write "requireSignature": true; without a sign-in, also give the publisher's keys (keys in follow.json), or every version is held.

Setting a project up again replaces an older npx -y instruction.md hook <host> entry with the new command. It never adds a second hook beside the old one.

What a session sees.

  • At its start, and again after /clear or /compact, the session gets the whole text as <instruction uri version digest>…</instruction>.

  • At a prompt while the instruction is unchanged, it gets nothing.

  • After a release, the model receives the new version in an update block:

    <instruction-update uri="instruction://acme/support@stable" from="v4" to="v5" digest="sha256:…">
    These instructions replace the earlier version of acme/support in full.
    …
    </instruction-update>
    

    The person sees one line: instruction.md: acme/support v4 → v5 (signature verified).

A long instruction. The hook gives at most maxInjectChars characters at once (9,000 by default). Claude Code takes up to 10,000 characters from a hook. A longer text is cut, followed by a line that asks the agent to read the whole text in .instruction/current.md.

Must not run without it. Add --fail-closed to the hook's command. When there is no copy of the instruction at all, the hook then blocks the prompt (or stops the session) and gives the reason. It does this through its answer to the app (for Claude Code, {"decision":"block","reason":…}), and still exits 0.

Your own Codex instructions, in every repository. Codex re-reads ~/.codex/AGENTS.md before every model request. The instruction command can keep an instruction there. --block writes only between two marker lines:

npx -y instruction.md watch acme/me@latest --out ~/.codex/AGENTS.md --block

Watching for new versions. instruction watch (in the instruction.md package), run without a URI, follows the project's follow.json and keeps .instruction/current.md up to date. With --lines, it prints one line on stdout for each version applied after it started. It doesn't print the version it starts on, because the session's start hook already gave that one. In Claude Code, a plugin monitor turns each line into a notice that wakes an idle session. In a project that follows nothing, it exits at once without output.

Guides: Claude Code · Codex.

The plugin

The plugin bundles all of this for Claude Code and Codex: the hooks, an MCP server, a skill on working with followed instructions and, in Claude Code, a monitor that tells an idle session about a new version. It is in github.com/instruction-md/plugins:

# Claude Code
/plugin marketplace add instruction-md/plugins
/plugin install instruction-md@instruction-md

# Codex
codex plugin marketplace add instruction-md/plugins
codex plugin add instruction-md@instruction-md

Put one instruction on every machine of an organization

instruction-agents follow acme/support@stable --host claude-code --managed   # managed-settings.json
instruction-agents follow acme/support@stable --host codex --managed         # requirements.toml

--managed writes nothing. It prints the settings for an administrator to deploy (with MDM, a configuration tool or an image). Every session on those machines then follows the instruction through npx -y @instruction.md/agents hook <host> --follow <uri> (--cli CMD changes the command, for example to an installed instruction-agents). The text of a follow given by its address is cached for the user, not the project. To make sure only signed versions reach anyone, require signatures twice:

  • on the ref: instruction refs <id> gate stable --require-signature;
  • in each binding: --require-signature, or "requireSignature": true in follow.json.

Guide: Managed agents.

Other coding agents

The same hook answers each agent in the form that agent accepts (instruction-agents hook <host>). follow <uri> --host <host> --write writes each agent's file, merged into what is there:

Agent--hostFile writtenWhen it gets the text
Claude Codeclaude-code.claude/settings.jsonSessionStart; a new version at UserPromptSubmit
Codexcodex.codex/hooks.jsonSessionStart; a new version at UserPromptSubmit
Gemini CLIgemini-cli.gemini/settings.jsonSessionStart; a new version at BeforeAgent; forgotten at PreCompress
Antigravityantigravity.agents/hooks.jsonSessionStart; a new version at PreInvocation
Qwen Codeqwen-code.qwen/settings.jsonSessionStart; a new version at UserPromptSubmit
Factory Droiddroid.factory/hooks.jsonas Claude Code
Devindevin.devin/hooks.v1.json (none if .claude/settings.json already runs the hook: Devin reads it)as Claude Code
GitHub Copilot CLIcopilot.github/hooks/instruction-md.jsonsessionStart; a new version after a tool call (under Copilot's 10 KB); forgotten at preCompact
Cursorcursor.cursor/hooks.jsonsessionStart; a new version after a tool call; forgotten at preCompact
Clinecline.clinerules/hooks/<Event> scriptsTaskStart/TaskResume; a new version at a prompt or after a tool call
Crushcrush.crushrc (hook add PostToolUse …)after a tool call (Crush takes context nowhere else)
Kiro, Juniekiro, junienone: the command tells you what to set in their own screensKiro: plain text at SessionStart and PromptSubmit; Junie: after a tool call

Notes on particular agents:

  • Gemini CLI and Qwen Code escape < and > in a hook's text. There the text goes without tags: --- instruction <uri> v5 (<digest>) --- … --- end of the instruction ---.

  • Kiro. follow --host kiro --write prints the steps to take in Kiro. One of them suggests npx -y @instruction.md/agents watch --out .kiro/steering/instruction-md.md. This package has no watch: run npx -y instruction.md watch <uri> --out .kiro/steering/instruction-md.md instead (the same output prints that form further down).

  • hook auto works out which agent is calling from what it was sent and from its environment. Most of these agents set Claude Code's variables too.

  • Goose, OpenCode, Kilo Code and Aider have no hook that adds text. They re-read a file every turn instead, and instruction watch (in the instruction.md package) keeps .instruction/current.md up to date. follow doesn't set them up: it answers these hosts with exit code 2. The instruction command prints what to add for each one (opencode.jsonc, kilo.jsonc, .aider.conf.yml, or Goose's GOOSE_MOIM_MESSAGE_FILE and extension):

    npx -y instruction.md connect --host opencode acme/support@stable   # or --host kilo, aider, goose
    

    It writes nothing. Run the watch line it prints, and add the rest to the agent's settings. For Goose, our plugin also runs hook goose, which refreshes the same file and adds nothing to the session.

  • Cursor can also use a rule that every chat applies, kept current:

    npx -y instruction.md watch acme/support@stable --out .cursor/rules/instruction-md.mdc --rule
    

Guide: Other coding agents.

Install an instruction as a subagent or a skill

instruction-agents install acme/reviewer@stable --host claude-code --as agent   # .claude/agents/reviewer.md
instruction-agents install acme/release@stable --host claude-code --as skill    # .claude/skills/release/SKILL.md
instruction-agents install acme/release@stable --host codex --as skill          # .agents/skills/release/SKILL.md

The file has the host's own front matter (name and description, taken from the instruction). Below it comes a line saying where the text came from (address, version and digest), then the delivered text. Run the command again to get a new version. It rewrites the file whole, or leaves it alone when nothing changed. Both hosts notice a changed subagent or skill within the session.

A file that install didn't write, or one written from another instruction, is left alone unless you pass --force. In a project that already follows an instruction, you can leave out the URI. If you are not signed in, the project's cached copy is used. Codex has no subagent files, so --host codex takes only --as skill.

pi, Amp and any ACP agent

These hosts run our code rather than a hook command. They use the same follow: the project's .instruction/follow.json, or INSTRUCTION_MD_FOLLOW=<uri> to follow one instruction in every project.

  • pi. This package is a pi package: pi install npm:@instruction.md/agents. Before every run, the extension puts the instruction in a section named instruction of pi's system prompt. pi patches only sections that changed, so a new version reaches a running session at its next prompt, at system level. You are told about a new version. For pi's SDK, use piExtension() from @instruction.md/agents/pi (see Reference).

  • Amp. The plugin file amp/instruction-md.ts is in github.com/instruction-md/plugins. Copy it into .amp/plugins/ or ~/.config/amp/plugins/. It gives the instruction at a thread's first turn and a new version at the next prompt. It runs instruction-agents turn amp --session <thread> [--start] --cwd <dir>, which prints { "context"?, "notice"? } or nothing.

  • Any ACP agent (in Zed, JetBrains or another ACP client). Run the agent through the proxy:

    npx -y @instruction.md/agents acp -- <agent command…>
    

    Where the agent accepts a system prompt from the client (sessionCapabilities.systemPrompt), the session's system prompt carries the instruction. Otherwise its first prompt does. After a release, the next prompt starts with the new version. The proxy also adds instruction.md's stdio MCP server to the session's MCP servers. Use --no-bridge to leave them alone. Messages pass through unchanged otherwise, and notes for the person go to stderr.

Each one reports the version a session applied, with its host name (pi, amp, acp).

Follow an instruction in your own agent (SDK)

npm install @instruction.md/agents

follow() reads over instruction.md's MCP server, which answers only a caller with a token, so it needs one even for a public instruction. It doesn't use the sign-in stored by login. Give it a token in INSTRUCTION_MD_TOKEN, or as token (a string, or a function asked before each read). For an agent you run, use an agent account:

  1. Create one, once (this needs an organization admin): instruction agents create my-agent --kind agent --org acme. It prints a client_id, a client_secret (shown once) and a token_url.
  2. Ask the token_url for a token with the OAuth client-credentials grant. A token lasts about five minutes, so pass a function that gets a new one as it runs out (below). instruction connect --host sdk --agent <client_id> <uri> prints the same code with your values.
import { follow } from "@instruction.md/agents/agent";

// a token for the agent account, fetched again shortly before it runs out
let minted = { token: "", until: 0 };
async function token() {
  if (Date.now() < minted.until) return minted.token;
  const r = await fetch(process.env.INSTRUCTION_MD_TOKEN_URL!, {
    method: "POST",
    body: new URLSearchParams({ grant_type: "client_credentials", client_id: process.env.INSTRUCTION_MD_CLIENT_ID!,
      client_secret: process.env.INSTRUCTION_MD_CLIENT_SECRET! }),
  }).then((res) => res.json() as Promise<{ access_token: string; expires_in: number }>);
  minted = { token: r.access_token, until: Date.now() + (r.expires_in - 30) * 1000 };
  return minted.token;
}

const ins = await follow("instruction://acme/support@stable", { token, requireSignature: true });

// Claude Agent SDK: the text in the system prompt, a new version at the next prompt
import { query } from "@anthropic-ai/claude-agent-sdk";
const prompt = "Work through today's queue.";
for await (const m of query({ prompt, options: {
  systemPrompt: { type: "preset", preset: "claude_code", append: ins.text },
  hooks: { UserPromptSubmit: [{ hooks: [async () => (await ins.changedSinceLastTurn())
    ? { hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: ins.updateBlock() } } : {}] }] },
} })) { /* … */ }

// Codex SDK: the text as the thread's developer instructions (a new version: start a new thread)
import { Codex } from "@openai/codex-sdk";
const codex = new Codex({ config: { developer_instructions: ins.text } });

follow() reads the version now, and throws when there is none to hand over: not found, not allowed, or held for its signature. Without a token, the read fails with read failed (hook): authentication required (the "hook" in it is a wrong label: it is follow()'s own read). Between turns, changedSinceLastTurn() reads again once refreshSeconds (60) have passed. It holds no live connection. A read that fails keeps the version in hand. Neither SDK is a dependency of this package: you pass the text and blocks to the SDK yourself. Call ins.close() when you are done.

Give an agent its servers, skills and sign-ins

An instruction can declare the MCP servers its agent uses, which tools it may or may not call, and the skills it can load. apply writes them into the agent's own files:

# in a project that follows an instruction
instruction-agents apply                    # Claude Code: .mcp.json, .claude/settings.json, .claude/skills/
instruction-agents apply --host codex       # Codex: .codex/config.toml, .agents/skills/
instruction-agents apply --host both --approve
instruction-agents apply --remove           # take back everything apply wrote
(blank)Claude CodeCodex
Servers.mcp.json mcpServers.codex/config.toml [mcp_servers.<id>]
CredentialsheadersHelper → instruction-agents credentialhttp_headers_helper → instruction-agents credential
Allowed and denied tools.claude/settings.json permissions (mcp__…)enabled_tools / disabled_tools
Skills.claude/skills/<id>/SKILL.md.agents/skills/<id>/SKILL.md
Approval--approve writes .claude/settings.local.jsonthe folder must be trusted (Codex's own rule)

apply changes and removes only what it wrote itself. It keeps a record in .instruction/applied.json, which you commit. A server or skill of the same name that someone else added is left alone, and apply tells you so. In a project set up with follow … --write, the hook applies again in the background whenever a session starts on a version that changes these. The agent's app loads them at its next session.

Next, say what each server's account means on this machine. instruction.md never holds these keys or tokens:

instruction-agents accounts set desk@work --env DESK_API_KEY                           # a key from a variable
instruction-agents accounts set desk@work --command "op read op://Work/Desk/token"     # from your secret store
instruction-agents signin desk --account work --url https://desk.example.com/mcp       # an OAuth sign-in
instruction-agents signin desk --account work --url https://desk.example.com/mcp --device   # a code on any device
instruction-agents accounts                                                            # what each uses (never a value)

Your company's identity provider can vouch for the agent (Cross-App Access, XAA). The agent then gets access with no browser at all, and you revoke it at the identity provider:

instruction-agents accounts set crm@corp \
  --xaa-idp https://login.corp.example/oauth2/v1/token \
  --xaa-client-id agents-runner --xaa-client-secret-env CORP_IDP_SECRET \
  --xaa-subject-command "corp-sso print-id-token" \
  --xaa-server-client-id instruction-md-agents

For an unattended machine, accounts host gives the agent's app its own sign-in. run sets it for each agent it starts:

claude setup-token
instruction-agents accounts host claude-code --env CLAUDE_CODE_OAUTH_TOKEN --from-command "vault kv get -field=token secret/agents/claude"
instruction-agents accounts host codex --env CODEX_API_KEY --from-command "vault kv get -field=key secret/agents/openai"

Then check before the agent starts:

$ instruction-agents check --host claude-code
✓ signed in; this project follows acme/desk (v7)
✓ Claude Code 2.1.329, signed in
✓ desk@work: desk.example.com takes this machine's credential
! wiki: wiki.example.com needs a sign-in — the agent's app will ask you
    fix: instruction agents signin wiki --url https://wiki.example.com/mcp

Codex runs the header command with only HOME and PATH set. A key from a variable is therefore handed to Codex in its own setting. A --command that needs other variables must set them itself, for example VAULT_ADDR=https://vault.example.com vault kv get ….

Guide: Servers, skills and sign-ins.

Run an agent for every deployed instruction

A deployment runs an instruction as an agent on a machine. You set it up in the editor:

  • Deploy to… on one instruction. Its command names a machine (--platform).
  • A rule on a project or a folder. Each instruction in scope becomes a deployment. Its command names the rule (--rule).

run starts one agent for each active deployment:

instruction-agents login --device      # once, on a machine with no browser
instruction-agents run --rule dpr_… -- claude -p "Work through today's queue."
instruction-agents run --platform laptop --org acme --once -- codex exec "Check the open reviews."
  • Folders. Each agent runs in its own folder, <dir>/<owner>__<name>/ (--dir, default ./instruction-fleet). The folder has a .instruction/follow.json that names its instruction, so the hooks and plugins already set up for Claude Code, Codex and the others follow it there. Before an agent starts, its servers and skills are written into its folder, and its sign-ins are checked.
  • Your command. It gets INSTRUCTION_MD_FOLLOW and INSTRUCTION_MD_DEPLOYMENT in its environment. In the command, {instruction} becomes the instruction's address, {name} its name and {dir} the agent's folder.
  • Starting and stopping. run reads the deployments every --interval seconds (default 60), and at once when the server announces a change. A new deployment starts. A retired one stops: SIGTERM first, then SIGKILL after 10 s.
  • A new release. What happens depends on the rule:
    • live (the default): the agent keeps running, and its hooks take the new version at its next turn;
    • restart: the agent is restarted;
    • approve: the agent stays on the approved version until someone approves the new one. Agents waiting for approval aren't started.
  • Limits. It never runs more agents than --max or the rule's own limit.
  • Reports. It reports each agent: running, its version, failed (with the last lines it wrote to stderr), or needs a sign-in. The editor shows this. --host APP names what runs (claude-code, codex, …).
  • --once makes one pass, waits for each command to end, and exits 1 if one failed. Use it for a cron job. --clean (with --once) removes the folders it made for deployments that are gone.
  • --dry-run prints what it would start and stop, and does nothing.
  • --restart-on-exit starts a command that exited again, after a growing pause.
  • Stopping run. Ctrl-C (or SIGTERM) stops every agent it started. It keeps its state in .instruction-fleet.json in the folder. It never deletes a folder it didn't make. Each agent's output is in its folder's .instruction/fleet.log.
  • Inside a Claude Code session. Each agent starts without Claude Code's own session variables (CLAUDECODE, CLAUDE_CODE_SESSION_ID, …), so it doesn't take over the outer session.

Talking with agents. If you give Claude Code its task as claude -p "…" (without --input-format or --output-format), run becomes Claude Code's host. Each question the agent asks, and each permission it requests, appears on instruction.md/agents as a card. Your answer, with an optional note, goes back to the agent. Anything that looks like a secret in a tool's input is masked (•••) before it leaves the machine, and long inputs are cut. From the same page you can write to an agent, interrupt it or restart it. Subagents that the agent starts (Claude Code's Task tool) appear under their agent. Other agents (Codex, your own scripts) get your messages at their next prompt or tool use, through the hook. Use --no-converse to run Claude Code without this.

Remote control in the Claude app. With --remote-control, each Claude Code agent becomes a session you control on claude.ai/code or in the Claude phone app. Its name is instruction.md: <owner/name>. The runner starts Claude Code interactively in a pseudo-terminal, gives it its task as the first message, and answers the folder-trust question for the folder it made. On /agents, the agent then has an Open in Claude link. This needs claude -p "<task>" as the command. It doesn't work with --once.

Sealed instructions. An instruction in a sealed workspace is end-to-end encrypted. The agent's hooks and run open it with the machine's key, given as INSTRUCTION_MD_SEAL_KEY_FILE or INSTRUCTION_MD_SEAL_KEY_COMMAND. Without the key, the version is held, with the reason. A sealed agent's conversation is sealed too: every line, question, permission, error and subagent name that run reports, and the answers and messages that come back. The server refuses that conversation in plain text.

Guides: Deployments · Talking with agents · Sealed instructions.

Reference

--help (or -h) on any command prints the full usage. instruction-agents --version (or -v, as the first argument) prints the package name and version. --host is always the agent's app (claude-code, codex, …). --as is what an instruction becomes (agent or skill).

Commands that talk to instruction.md also take --url U (the MCP server, default INSTRUCTION_MD_URL, then the stored sign-in's server, then https://instruction.md/mcp) and --token T (a bearer token, used exactly as given).

Commands for people

follow <uri> --host HOST [--write] [--require-signature] [--dir D] [--cli CMD] [--no-apply] [--json]

Makes a project follow <uri>. It writes .instruction/follow.json and the app's hooks. Without --write, it prints them instead.

FlagDefaultMeaning
--host(required)claude-code, codex, qwen-code, droid, devin, gemini-cli, antigravity, copilot, cursor, cline, crush, kiro, junie (Kiro and Junie: printed steps). Other hosts exit 2: see Other coding agents
--writeoffwrite the files into the project, merged into what is there
--require-signatureoffwrite "requireSignature": true
--dir Dcurrent directorythe project
--cli CMDnpx -y @instruction.md/agentsthe command the hooks run
--no-applyoffdon't write the instruction's servers and skills, and don't set apply
--jsonoffthe result as JSON

<uri> may be owner/name, owner/name@ref, or a full instruction:// address.

follow <uri> --host claude-code|codex --managed

Prints the organization-wide settings that an administrator deploys: Claude Code's managed-settings.json, or Codex's requirements.toml. It writes nothing, and can't be combined with --write.

install [<uri>] --host claude-code|codex --as agent|skill [--name N] [--dir D] [--force]

Writes an instruction as the app's own file: .claude/agents/<name>.md, .claude/skills/<name>/SKILL.md or .agents/skills/<name>/SKILL.md. --name sets the file's name. The default is the instruction's name, in lowercase letters, digits and hyphens, at most 64 characters. --force overwrites a file that install didn't write.

run (--rule dpr_… | --platform LABEL [--org SLUG]) [flags] -- <command…>
FlagDefaultMeaning
--rule dpr_…the deployments of one rule
--platform LABELevery deployment for this machine name
--org SLUGwith --platform: the organization, by slug or id
--dir D./instruction-fleetwhere the agents' folders go
--max Nnoneat most N agents (a whole number above 0)
--interval S60seconds between reads (at least 1)
--onceoffone pass; wait for each command; exit 1 if one failed
--dry-runoffprint what it would start and stop
--restart-on-exitoffstart a command that exited again, after a growing pause
--cleanoffwith --once: remove the folders of deployments that are gone
--host APPfrom the commandwhat runs, for reports (claude-code, codex, …)
--accounts FILEthe accounts filethe accounts file for these agents
--no-applyoffdon't write servers and skills into the folders
--no-converseoffdon't host Claude Code's questions and permissions
--remote-controloffeach Claude Code agent as a Remote Control session (not with --once)
--cli CMDnpx -y @instruction.md/agentsthe command the agents' header helpers run

Exit codes: 0; 1 when --once saw an agent fail; 2 for a usage error; 3 when not signed in; 4 for an unknown --org.

apply [<uri>] [--host claude-code|codex|both] [--dir D] [--approve] [--dry-run] [--remove] [--cli CMD] [--json]

Writes the instruction's MCP servers, tool rules and skills into the app's files.

  • <uri>: the default is the project's follow.json.
  • --host: the default is follow.json's apply, then the last apply, then claude-code. A comma-separated list is accepted.
  • --approve (Claude Code) approves the servers for you.
  • --remove takes back everything it wrote.
  • --if-changed, --quiet and --note are used by the hook's background apply.

Exit codes: 0; 1 on an error; 2 for a usage error; 3 when not signed in.

check [--host claude-code|codex|both] [--dir D] [--fleet] [--no-probe] [--json]

Checks your instruction.md sign-in, the agent's app's own sign-in (and when it runs out), and each server's account on this machine. Each problem comes with the command that fixes it. --fleet checks the way an unattended machine needs: anything that would wait for a person counts as blocking. --no-probe doesn't contact the servers. Exit codes: 0 when nothing blocks; 1 when something does; 2 for a usage error.

accounts

Says what an instruction's account means on this machine. It never prints a value.

instruction-agents accounts [list] [--json] [--file F]
instruction-agents accounts set <server[@account]> (--env VAR | --command CMD | --oauth | --xaa-idp URL …) [--header NAME] [--scheme WORD]
instruction-agents accounts host <claude-code|codex> --env VAR (--from-env V | --from-command C)
instruction-agents accounts remove <server[@account]>
instruction-agents accounts remove-host <name>
OptionMeaning
--env VARthe credential is in the variable VAR
--command CMDa command prints it (run with your rights through /bin/sh -c, at most 20 s)
--oautha sign-in made with signin
--xaa-idp URLyour identity provider's token address (XAA); needs --xaa-client-id, --xaa-server-client-id, and --xaa-subject-env or --xaa-subject-command
--xaa-client-secret-env / --xaa-client-secret-commandthe runner's client secret at the identity provider
--xaa-server-client-secret-env / --xaa-server-client-secret-commandthe client secret at the server's authorization server
--xaa-scope S, --xaa-audience ISSthe scope asked for; the server's authorization server (found from the server when not given)
--header NAMEthe header the credential goes in (default Authorization)
--scheme WORDwhat comes before the value (default Bearer; "" for the value alone)
--file Fa different accounts file

A server is looked up as id@account first, then as id. remove also deletes the server's stored tokens. Exit code 4 means there is no such entry.

signin <server> [--url U] [--account A] [--device] [--no-browser] [--scope S] [--client-id ID [--client-secret-env V]]

Signs this machine in to an MCP server with OAuth. It opens a browser here. With --device, it shows a code to enter on any device, where the server offers that. With --no-browser, or over SSH, it prints a link to open on any device; you then paste back the address of the page you end on, which starts with http://127.0.0.1. When --url is not given, it takes the server's address from the stored tokens or from .instruction/applied.json (--help shows --url as if it were required; it isn't). It records the server as --oauth in the accounts file.

login [--device] [--no-browser] [--url U] · whoami

login signs in to instruction.md. It is the same sign-in as instruction login, kept in the same place. whoami says who the server says you are.

Commands the agent's app runs

hook HOST|auto [--event NAME] [--fail-closed] [--follow URI [--require-signature]] [--dir D] [--url U] [--deadline MS]

The event arrives as JSON on stdin. The answer goes to stdout in the host's form, or nothing is printed. It exits 0, also with --fail-closed (which blocks through the answer); problems go to stderr. Only a usage error, such as an unknown host, exits 1.

FlagDefaultMeaning
HOSTclaude-code, codex, qwen-code, droid, devin, gemini-cli, antigravity, copilot, cursor, kiro, cline, junie, crush, goose, or auto (told from the event and environment)
--event NAMEfrom stdinthe event, for an app that doesn't name it on stdin
--fail-closedoffwith no copy at all, block the prompt (or stop the session) through the answer; still exits 0
--follow URIfollow.jsonfollow by address (managed settings); its copy is cached for the user
--require-signatureoffonly signed versions
--dir Dthe event's cwdwhere to look for .instruction/follow.json (searched upward)
--deadline MS1500how long a read may take before the last good copy is used
acp [--follow URI [--require-signature]] [--url U] [--no-bridge] -- <agent command…>

An ACP proxy (see above).

turn <app> --session ID [--start [--source S]] [--cwd D] [--follow URI [--require-signature]] [--url U] [--deadline MS]

One turn, for a plugin that can only run a command (Amp's). It prints JSON { "context"?, "notice"? } on stdout, or nothing, and always exits 0. --source is one of startup, resume, clear, compact or fork.

credential <server> [--account A] [--url U] [--accounts FILE] [--show]

Prints the headers for a server as JSON on stdout. Claude Code's headersHelper and Codex's http_headers_helper run it. It refuses to print to a terminal unless you pass --show. When run by Claude Code, it falls back to CLAUDE_CODE_MCP_SERVER_NAME and CLAUDE_CODE_MCP_SERVER_URL. A token from a sign-in is refreshed when it nears its end. Exit codes: 2 for a usage error or a terminal; 3 when the credential is missing (with what to do); 4 when there is no account entry.

mcp …

instruction.md's stdio MCP server (the same as instruction mcp). The ACP proxy uses it as the session's bridge.

Earlier names

These still work, so settings and scripts written before keep running:

Earlier nameCurrent name
connect --host H <uri> --with-hooksfollow
sync --as claude-agent|claude-skill|codex-skillinstall
fleetrun
doctorcheck

The instruction command hands instruction hook, instruction fleet, instruction credential and the other moved commands to this package.

follow.json

.instruction/follow.json sits in the project. It is found by searching upward from the agent's working directory.

KeyTypeDefaultMeaning
followstring(required)instruction://{id}@{ref}, instruction://owner/name[@ref] or owner/name[@ref]
requireSignaturebooleanfalseapply only versions whose author signature verifies; others are held
keysstringsigned in: the publisher's keys from instruction.md; not signed in: nonea JSON file of accepted author keys (JWK, { "keys": [...] } or [...]), relative to the project. Without a sign-in, requireSignature needs it
urlstringINSTRUCTION_MD_URL, else https://instruction.md/mcpthe MCP server
refreshSecondsnumber60how old current.md may get before a hook reads again
maxInjectCharsnumber9000the most text given at once; past that, the agent is told to read current.md
apply("claude-code" | "codex")[]nonewrite the instruction's servers and skills for these apps when a version changes them
deploymentIdstringwritten by run: the deployment this folder's agent is
conversebooleanwritten by run: the runner itself delivers people's messages, not the hook

Files

PathCommit it?What it is
.instruction/follow.jsonyeswhat the project follows
.instruction/applied.jsonyeswhat apply wrote, so a teammate's apply knows which entries are its own
.instruction/.gitignoreyeskeeps the next three out of git
.instruction/current.mdnothe last good copy of the delivered text
.instruction/state.jsonnowhich version each session holds
.instruction/given/nomarkers that make sure a session gets a version once when two hooks fire; pruned after 14 days
.instruction/fleet.log, mcp.json, claude-settings.jsonnoin a run folder: the agent's output; Claude Code's servers and permissions, passed as flags
<dir>/.instruction-fleet.jsonnorun's own state
~/.config/instruction-md/credentials.jsonthe instruction.md sign-in (login)
~/.config/instruction-md/accounts.jsonwhat each account means on this machine (mode 0600)
~/.config/instruction-md/mcp-tokens.jsontokens from signin and XAA (mode 0600)
~/.cache/instruction-md/the copy of an instruction followed by its address (--follow, INSTRUCTION_MD_FOLLOW)

~/.config is $XDG_CONFIG_HOME when that is set, and ~/.cache is $XDG_CACHE_HOME.

Environment variables

VariableRead byMeaning
INSTRUCTION_MD_TOKENalla bearer token, used instead of the stored sign-in (for example an agent's client-credentials token)
INSTRUCTION_MD_URLallthe MCP server (default https://instruction.md/mcp)
INSTRUCTION_MD_FOLLOWpi, turn, acp; set by runfollow this address where no follow.json is found
INSTRUCTION_MD_REQUIRE_SIGNATUREwith INSTRUCTION_MD_FOLLOW1: only signed versions
INSTRUCTION_MD_DEPLOYMENTset by runthe agent's deployment id
INSTRUCTION_MD_ACCOUNTSaccounts, credential, runthe accounts file
INSTRUCTION_MD_MCP_TOKENSsignin, credentialthe server tokens file
INSTRUCTION_MD_CACHEhooksthe cache directory for follows by address
INSTRUCTION_MD_SEAL_KEY_FILEhooks, runan imd-seal/1 key file that opens sealed instructions and conversations
INSTRUCTION_MD_SEAL_KEY_COMMANDhooks, runa command that prints that key file (from a KMS or secret store)
INSTRUCTION_MD_SEAL_PASSPHRASE, INSTRUCTION_MD_SEAL_RECOVERYhooks, rununlock the person's own seal key instead
INSTRUCTION_MD_CLIENT_NAMEallthe client name sent to the server (set for you, so the server can count reads by app)
XDG_CONFIG_HOME, XDG_CACHE_HOMEallthe config and cache base directories
CLAUDE_CODE_MCP_SERVER_NAME, CLAUDE_CODE_MCP_SERVER_URLcredentialset by Claude Code for a header helper

@instruction.md/agents/agent

function follow(uri: string, options?: FollowOptions): Promise<Followed>;

FollowOptions:

OptionTypeDefaultMeaning
urlstringINSTRUCTION_MD_URL, else https://instruction.md/mcpthe MCP server
tokenstring | () => string | undefined | Promise<string | undefined>INSTRUCTION_MD_TOKENa bearer token, or a function asked before each read. Required, even for a public instruction (unless you pass client)
clientFollowerClient (readResource and callTool, as the MCP SDK's Client has)your own client; url and token are then not used
requireSignaturebooleanfalseonly versions whose author signature verifies
keysJWK[]the publisher's keys, read from instruction.md with your tokenthe author keys accepted
refreshSecondsnumber60how long a version is used before the next read
deadlineMsnumber5000how long a read may take before the version in hand is kept
now() => numberDate.nowthe clock (for tests)

Followed:

MemberMeaning
uri, labelthe address followed; owner/name (or the address)
textthe delivered text of the version in hand
version, versionIdits number (1, 2 …) and id
digestsha256:… of the delivered text
verifiedits author signature was checked and holds
currentthe version in hand, whole (Current)
refresh(): Promise<boolean>read now; true when a new version came (a failed read: false)
changedSinceLastTurn(): Promise<boolean>read again once refreshSeconds passed; true once per new version
updateBlock(): stringafter changedSinceLastTurn() answered true: the <instruction-update> block for the model
contextBlock(): stringthe version in hand as the block a host gets at a session's start
close(): Promise<void>closes the client it made (never one you passed)

@instruction.md/agents/pi

import { piExtension } from "@instruction.md/agents/pi";
const extension = piExtension({ follow: "instruction://acme/support@stable", requireSignature: true });
  • default: the extension with default options. pi loads it after pi install npm:@instruction.md/agents.
  • piExtension(options?: PiOptions): (pi: PiApi) => void. The options:
    • follow (string): an address to follow, instead of the project's follow.json;
    • requireSignature (boolean);
    • url (string, default follow.json's url, then INSTRUCTION_MD_URL, then https://instruction.md/mcp);
    • deadlineMs (number, default 1500);
    • access and now, for tests.
  • piSection(cur: Current): string: the section's text.
  • PI_SECTION: "instruction", the name of the system-prompt section.
  • Types: PiApi, PiContext, PiBeforeAgentStart, PiOptions, Access, Current, FoundFollow, Reader.

The extension imports nothing from pi. pi supplies the API object.

Security

  • What is sent, and where. Reads and reports go only to the MCP server you use. That is https://instruction.md/mcp unless you set --url, INSTRUCTION_MD_URL or follow.json's url.
    • A hook sends the instruction's address. When you are signed in, it also reports the version and digest a session applied, the app's name, and this machine's host name (in the binding's consumer name).
    • run sends each agent's state and the last lines of its stderr. For a hosted Claude Code agent, it also sends what the agent says and runs, and its questions and permission requests, with likely secrets masked.
    • Your source code, prompts and files are never sent by the hooks.
  • Credentials stay on the machine. The instruction.md sign-in is bound to the server it was issued for, and is never sent to another server. Server credentials come from a variable, a command or a local sign-in. They are kept in files readable only by you (accounts.json, mcp-tokens.json, mode 0600), and credential hands them only to the agent's app. instruction.md never receives them. signin finishes on your machine (127.0.0.1), so a link someone sends you can't sign their machine in as you.
  • Signatures. With requireSignature, a version is applied only if its author signature verifies against the publisher's keys (read from instruction.md when signed in) or the keys in follow.json's keys file. A version that fails is held, and the last good one stays. A revoked version is held too. See Signing.
  • Sealed content. Sealed instructions and conversations are opened only with the machine's key. They are never passed to an agent as ciphertext, and a message that doesn't open is dropped. The seal library is beta and has not had an independent cryptographic review yet. See Sealed instructions.
  • What an instruction is not. The text reaches the agent as context it is told to follow. It doesn't lock what the agent can do. Use each app's permission settings for that. apply writes an instruction's deny lists as the app's own rules.
  • Reporting a vulnerability. Please don't open a public issue. Use Contact us and choose Security. SECURITY.md, in the source repository, has the details.

Compatibility and versioning

  • The package follows semantic versioning. While it is 0.x, a minor release (0.4 → 0.5) may change commands, flags or the module APIs, and the changelog says so. A patch release (0.4.1 → 0.4.2) doesn't break anything. Pin a minor range (~0.4.0) if you depend on details.
  • Command and flag names that are replaced keep working, as the earlier names do. Hook settings that a project committed keep working across releases.
  • It speaks MCP 2026-07-28 (stateless) to instruction.md's server. Some features need a server from 2026-11-21 or later: subagents, remote control and sealed conversations.
  • The behaviour of each host was checked against particular versions, for example Claude Code 2.1.329 and 2.1.330, Codex 0.170.0, pi 1.5.2, and ACP schema v1.33.0. A host that changes its hook format may need a newer release of this package.

Troubleshooting

  • Nothing happens in a Claude Code or Codex session. Approve or trust the project's hooks; each app asks once. Check that .instruction/follow.json is in the project, or in a folder above it. Pipe an event into the hook by hand, as in the Quickstart, and look at stderr.
  • "couldn't read … this session goes on without it". The hook had no copy and the read failed. Sign in (instruction-agents login), or check the address. Use --fail-closed where a session must not run without the instruction.
  • "no keys to verify … name the publisher's keys in follow.json ("keys"), or sign in". You require signatures without a sign-in, so the hook can't get the publisher's keys. Sign in (instruction-agents login), or put the publisher's public keys in a file and name it as keys in follow.json.
  • follow … --host opencode (or kilo, aider, goose) exits 2. These hosts aren't set up by follow. Use npx -y instruction.md connect --host <host> <uri>, as in Other coding agents.
  • follow() throws "read failed (hook): authentication required". The SDK helper needs a token, even for a public instruction. Set INSTRUCTION_MD_TOKEN or pass token.
  • "a newer version … is held". The new version failed the policy: it is unsigned while you require signatures, its signature was refused, it is revoked, or it is sealed and the machine has no key. The last good version stays.
  • Codex cuts the instruction. Use the hooks that follow --host codex --write writes. They set additionalContextLimit: 0.
  • run says to sign in. It reads your organization's deployments. Run instruction-agents login --device, or set INSTRUCTION_MD_TOKEN.
  • An agent shows "Needs sign-in". Run instruction-agents check --fleet in its folder, then the fix: command it prints.
  • Questions don't reach instruction.md. Give Claude Code its task as claude -p "…", without --input-format or --output-format.
  • --remote-control runs without remote control. It needs claude -p "<task>" as the command, the script command (Linux or macOS), and a claude.ai sign-in rather than an API key.
  • credential prints nothing in a terminal. That is on purpose. Use instruction-agents check, or --show.

Contributing

Bug reports and fixes are welcome. See CONTRIBUTING.md in the source repository (it is not in the npm package).

Changelog

Every release is in CHANGELOG.md, with what changed for people upgrading. The file is in the source repository, not in the npm package; npm lists every published version here. The history from before 0.1.0, when these commands were part of the instruction.md package, is in that package's changelog.

License

MIT, © 2026 TSOK Inc. See LICENSE. NOTICE covers the material under other licenses that comes with the instruction.md dependency: the specification's registry and schemas (CC BY 4.0), its conformance vectors (Apache-2.0) and Lucide's icons (ISC).