Shareable AI tasks in Markdown.
A task = a small form + a prompt. Instructor asks the questions, builds the prompt and hands it to the agent of your choice (Claude Code, Codex, Gemini CLI, or any other CLI).
$ instructor add-component
◆ Which component do you want to install?
│ ● Button ○ Modal ○ DataTable
◇ Component name? UserCard
◇ Generate tests? Yes
└ → Claude Code (interactive)
Available on npm: instructor-cli.
npm i -g instructor-cli
instructor # first launch: pick your AI agent (change it later with `instructor config`)Prefer an editor? The VS Code extension (source) runs, previews, installs and publishes tasks through this CLI.
| Command | What it does |
|---|---|
instructor <task> |
run a task (alias for instructor run <task>) |
instructor |
list tasks and pick one |
instructor list |
project, installed and global tasks |
instructor init |
create an example INSTRUCTOR.md at the project root |
instructor create |
interactive wizard to write a task |
instructor generate "<description>" |
the AI writes the task for you (validated, retried if invalid) |
instructor install <url> |
install from a gist or a .md URL (-g: outside the project) |
instructor install |
reinstall everything in the lockfile, at the pinned revisions |
instructor remove [task...] (rm) |
delete tasks, even invalid ones (--scope project|installed|global, -y); removed installed tasks don't come back on install |
instructor publish [task...] |
publish tasks to a GitHub gist and print the install command to share |
instructor login / logout |
connect to GitHub (not needed if the GitHub CLI gh is logged in) |
instructor config |
default agent, install missing agents, custom agent |
run options:
instructor add-component --dry-run # print the prompt, start nothing
instructor add-component -s component=Modal -s tests=yes --headless # no questions (CI)
instructor add-component --agent codex # force an agent
instructor add-component -y # use defaults, no confirmationAt the end of a form, Instructor asks "Save these answers for next time?":
- pre-fill the form: next time, the questions are asked again, already filled in;
- skip the form: next time, no questions; the saved answers are used directly (only new questions are asked).
Answers are saved per project and per task in your config folder (answers.json), never in the repo.
--ask shows the form anyway, --forget clears them, --set overrides a saved answer, and with -y saved answers replace the defaults.
A single file can hold several tasks. Each one starts with a frontmatter whose first key is task:.
---
task: add-component
description: Adds a UI component
agent: claude # optional: otherwise your default agent
mode: interactive # interactive | headless
questions:
- id: component
type: select # text | select | multiselect | confirm
message: Which component do you want to install?
choices: [Button, Modal, DataTable]
- id: tests
type: confirm
message: Generate tests?
default: true
---
Create a component based on {{component}} in {{project.name}}.
{{#if tests}}Add tests.{{/if}}By default the user answers in the form. answer: changes that, and the question is then never shown:
- id: style
type: select
message: Which styling approach does the project use?
choices: [css-modules, tailwind, styled-components]
answer: ai # the agent answers by looking at the project
- id: license
type: select
message: License header?
choices: [MIT, none]
default: MIT
answer: default # always the default valueanswer |
Who answers |
|---|---|
user (default) |
the user, in the form |
ai |
the agent, in one headless call before the task starts (it sees the project and the user's answers); the result is displayed, and invalid answers are retried once |
default |
nobody: the default value is always used |
--set id=value still overrides any of them. With --dry-run, AI answers are shown as «AI answer: …» placeholders (no agent is started).
The body is a Handlebars template:
{{id}}: the answer to a question{{project.name}},{{date}},{{cwd}},{{agent}}: always available{{#if x}}…{{/if}},{{#if (eq x "Modal")}}…{{/if}},{{#if (includes list "a")}}…{{/if}}{{join list ", "}}or{{#each list}}- {{this}}{{/each}}for amultiselect
Instructor warns about variables used in the prompt that no question defines.
The project root is the closest folder (going up) that has a task file, .instructor/, package.json or .git,
but never your home folder or above: without such a marker, the current folder is the project.
In priority order (on duplicate names, the first one found wins):
INSTRUCTOR.md(orINSTRUCTION.md, same thing) at the project root: versioned with the code.instructor/*.md: tasks installed in the project (+instructor.lock.json)~/.config/instructor/tasks/*.md: global tasks (install -g)
instructor publish add-component # → https://gist.github.com/you/abc123…
instructor install https://gist.github.com/you/abc123… # on another machine / for a teammate
instructor install https://gist.github.com/you/abc123… --run # install and start it right awayAfter installing, Instructor offers to run a task now. --run starts it without asking (--run <task> when the gist holds several tasks).
- Gists are secret by default (only people with the link see them);
--publiclists it on your profile. - One task →
<task>.md; several → a singleINSTRUCTOR.mdin the gist. - Publishing the same tasks again updates the same gist (a new revision);
--newforces a new gist. - GitHub access, in order:
GH_TOKEN/GITHUB_TOKEN, the token saved byinstructor login(a token with thegistscope, stored in the config file), or the GitHub CLI session (gh auth login).
| id | CLI | interactive | headless |
|---|---|---|---|
claude |
Claude Code | claude "<prompt>" |
claude -p "<prompt>" |
codex |
Codex | codex "<prompt>" |
codex exec "<prompt>" |
gemini |
Gemini CLI | gemini -i "<prompt>" |
gemini -p "<prompt>" |
Custom agent, in ~/.config/instructor/config.json (or via instructor config → "Other command"):
{
"defaultAgent": "my-agent",
"custom": {
"my-agent": { "command": "my-agent", "args": ["{{prompt}}"], "headlessArgs": ["--print", "{{prompt}}"] }
}
}An installed task drives an agent that has access to your terminal. Instructor:
- shows the prompt and questions before installing, and asks for confirmation;
- pins the gist revision (or the SHA-256 of a raw URL) in the lockfile, and refuses to reinstall if the content changed;
- shows the final prompt before running a task that does not come from the project;
- passes the prompt to the agent without a shell: a form answer cannot inject a command.
npm install
npm test # unit tests (node:test)
npm link # makes the `instructor` command available locally- Conditional questions (
when: framework == react) - Deterministic steps before/after the agent (
before: npm install,after: npm test), with confirmation instructor updateto move a gist to its latest revision and show the diff- Pass the prompt via stdin or a temp file for very long prompts (command-line length limit on Windows)
- Dotprompt compatibility