Droid — AI Coding Agent Cheatsheet
Set up and operate Droid, Factory's terminal-native AI coding agent: install the CLI, run reviewable sessions, tune autonomy and Spec Mode, teach it your repo with AGENTS.md, skills, and custom droids, extend it with MCP and hooks, and automate work with headless droid exec and Missions.
Droid — AI Coding Agent Cheatsheet
One-line: Droid is Factory’s terminal-native AI coding agent: it reads your repo, proposes diffs, and waits for approval, then scales from interactive sessions to headless droid exec runs and multi-agent Missions.
Prerequisites
- A terminal open in a Git repository (recommended for the full workflow)
- A Factory account — Droid signs you in through the browser on first run
- Optional: Homebrew on macOS, or Node.js for the npm installer
- Linux only:
xdg-utils— install withsudo apt-get install xdg-utils - For headless or CI use: a Factory API key from API keys settings
Installation
Pick one installer, then start Droid from any project directory.
# macOS / Linux — standalone installer
curl -fsSL https://app.factory.ai/cli | sh
# Homebrew
brew install --cask droid
# npm
npm install -g droid
# Windows PowerShell
irm https://app.factory.ai/cli/windows | iex
cd /path/to/your/project
droid
The first launch opens the full-screen TUI and asks you to sign in via the browser. Verify the install:
droid -v
For headless or CI runs, authenticate with an API key instead of a browser session:
export FACTORY_API_KEY=fk-...
Standalone installs update themselves. Run droid update --check to check, droid update --version <VERSION> to pin or roll back, or set FACTORY_DROID_AUTO_UPDATE_ENABLED=false to disable the in-process updater. npm installs are pinned at build time.
Step-by-Step Setup & Optimization
Step 1 — Run your first reviewable session
-
Start a session in your project:
droid -
Ask Droid to map the codebase before it changes anything:
analyze this codebase and explain the overall architecture -
Request one small, verifiable change:
add structured logging to the app entry point and replace the existing console calls -
Review the proposed diff in the TUI and accept or reject it. With
Auto (Off), nothing is edited without your approval.
droid opens the TUI, answers with a file-cited architecture summary, and shows edits as a diff you approve before anything is applied.Press ? for the keyboard shortcut pane, Shift + Enter for multi-line prompts, and ! to run a shell command without AI interpretation. Ctrl + O toggles the detailed transcript.
Step 2 — Configure models, autonomy, and safety
-
Open
/settingsinside a session; changes apply immediately and save to the settings file. -
Know where settings live:
- macOS / Linux:
~/.factory/settings.json - Windows:
%USERPROFILE%\.factory\settings.json - Overrides:
settings.local.jsonbeside it, or<project>/.factory/settings.local.json(gitignore it)
- macOS / Linux:
-
Set your session defaults in
settings.json:{ "sessionDefaultSettings": { "interactionMode": "spec", "autonomyLevel": "low" }, "enableDroidShield": true, "cloudSessionSync": true } -
Learn the four autonomy levels — what Droid can run without pausing:
Off— built-in read tools plus policy-allowed commandsLow— file edits and low-risk commandsMedium— installs, builds/tests, and local git commitsHigh— pushes, deploy scripts, and migrations Cycle withCtrl+L; organization policy (maxAutonomyLevel) can cap the highest level.
-
Replace legacy command lists with tested
permissionRules, then validate:{ "permissionRules": { "version": 1, "rules": [ { "id": "user/git-push", "decision": "ask", "match": { "prefix": ["git", "push"] } } ] } }droid rules check --command 'git push origin main' -
Switch models mid-session with
/modelorCtrl+N. Custom BYOK models live undercustomModelsin the same file (see Reference).
droid rules check exits 0 and prints the policy decision for the command you previewed.Step 3 — Plan bigger changes with Spec Mode
-
Toggle Normal and Spec Mode with
Shift+Tab, or start in Spec Mode directly:droid --use-spec -
Describe the goal and constraints; Droid plans read-only — no edits, commits, or service changes — then asks for approval when the plan is ready.
-
On approval, pick the autonomy level for execution.
Offkeeps manual approvals;Low/Medium/Highpre-authorize work at or below that risk level (a plan approval dialog or/settingscan change it). -
Enable Save spec as Markdown in
/settingsto keep plans on disk;specSaveDiroverrides the spec store location. -
Reach for Spec Mode on architecture changes, migrations, and security-sensitive work; for headless planning use
droid exec --use-spec "<GOAL>".
droid --use-spec starts in Spec Mode, and Droid presents a written plan for approval before any edit.Step 4 — Teach Droid your repo: AGENTS.md, skills, custom droids
-
Add an
AGENTS.mdat the repository root with the project overview, exact commands, layout, conventions, verification steps, and safety rules. Nested files override where a package needs different rules; Droid also readsCLAUDE.mdfor compatibility. Keep it small — the initial guideline load caps at 80,000 characters and dynamic discovery at 40,000. -
Move long runbooks out of
AGENTS.mdinto skills:.factory/skills/<NAME>/SKILL.md(project) or~/.factory/skills/<NAME>/SKILL.md(personal).nameanddescriptionare required; invoke skills as/skill-name.--- name: release-check description: Verify release readiness. Use when the user asks to cut or prepare a release. --- 1. Run the test and lint commands from AGENTS.md. 2. Update CHANGELOG.md and bump the version. -
Add specialists as custom droids:
.factory/droids/<NAME>.md(project) or~/.factory/droids/(personal). Built-ins areworker(all tools) andexplorer(read-only); manage them with/droids.--- name: code-reviewer description: Focused reviewer that checks diffs for correctness risks model: inherit tools: read-only --- You are the team's senior reviewer. Examine the shared diff and flag correctness, security, and migration risks.
/skills and /droids list your new skill and custom droid in their managers.Keep secrets, customer data, and full copies of long docs out of AGENTS.md and skill folders — link to the source of truth instead.
Step 5 — Connect tools: MCP and hooks
-
Add an MCP server from the registry with
/mcp→ Add from Registry, or from the CLI:droid mcp add linear https://mcp.linear.app/mcp --type http -
Check server status:
droid mcp list -
Know the config layers:
~/.factory/mcp.json(user),.factory/mcp.json(project, committed), or an ancestor folder’s.factory/mcp.json. Servers added viadroid mcp addgo to the user config; project servers can only be changed by editing the file. -
Register hooks for lifecycle automation in
~/.factory/hooks.json(personal) or.factory/hooks.json(project):{ "PostToolUse": [ { "matcher": "Create|Edit|ApplyPatch", "hooks": [ { "type": "command", "command": "python3 \"$FACTORY_PROJECT_DIR\"/.factory/hooks/format_changed_file.py", "timeout": 30 } ] } ] }
droid mcp list shows each server’s status (connected, connecting, needs authentication, or failed).Project .factory/mcp.json is committed — never put tokens in it; keep secrets in ~/.factory/mcp.json or env vars. Hooks run automatically with your local credentials, so review every command and use absolute paths.
Step 6 — Automate with headless droid exec
-
Run a one-shot task (read-only by default):
droid exec "analyze code quality" -
Raise autonomy per run with the lowest tier that works:
droid exec --auto low "add JSDoc comments to all exported functions"droid exec --auto medium "install deps, run tests, and fix failing checks" -
Feed prompts from files or stdin, and emit structured output:
droid exec -f .factory/prompts/review.mdgit diff | droid exec "draft release notes"droid exec --output-format json "summarize this repository" -
Isolate parallel work in git worktrees:
droid exec --worktree codemod-a --auto medium "apply codemod A" & droid exec --worktree codemod-b --auto medium "apply codemod B" & wait -
In CI, export
FACTORY_API_KEYand treat a non-zero exit as failure; runs fail fast when they exceed the autonomy level:- name: Droid analysis env: FACTORY_API_KEY: ${{ secrets.FACTORY_API_KEY }} run: droid exec --auto low -f .github/prompts/review.md
droid exec --auto low "list the top-level directories" prints the result and exits 0 (droid exec returns non-zero on failure).--skip-permissions-unsafe skips every permission prompt (command blocks still apply). Use it only in disposable, isolated environments such as ephemeral CI containers — never on a workstation or shared runner.
Step 7 — Scale out: Missions and cloud sessions
-
Launch a Mission when the work is too big for one session:
/missionsin the TUI, or headless:droid exec --mission --auto high "coordinate the migration" -
Plan first: Missions break the goal into features and milestones, pull in skills, and require plan approval before Mission Control starts. They need High autonomy (or
--skip-permissions-unsafe) and a repo at Agent Readiness Level 4+ with a scriptable way to exercise the app (/readiness-report, then/readiness-fix). -
Keep sessions reachable anywhere:
cloudSessionSync(defaulttrue) mirrors CLI sessions to the web app, anddroid --resumepicks a session back up locally. -
Register this machine as a Bring-Your-Own-Machine computer for persistent remote compute:
droid computer register laptop
/missions opens the Missions flow and returns a feature-and-milestone plan you approve before Mission Control begins.Missions are not fire-and-forget — steer the orchestrator when it stalls. Never convert a long-running normal session into a Mission; start a new one so the upfront planning and validation structure survives.
Best Practices
Do
- ✅ Start read-only: map the repo before edits, and in CI use the lowest
--autolevel that completes the job. - ✅ Keep
AGENTS.mdshort and scoped (root file plus per-package overrides); link out instead of pasting runbooks. - ✅ Plan with Spec Mode for architecture, migrations, and security-sensitive changes, then raise autonomy after approval.
- ✅ Route models by role: stronger models for spec planning, Mission orchestrators, and validators; lighter ones for workers (
sessionDefaultSettings.specModeModel,missionModelSettings.*,subagentModelSettings.*). - ✅ Preview command policy with
droid rules check --command '...'before relying on a rule in automation. - ✅ Keep the MCP surface narrow, and keep credentials out of committed project config.
- ✅ Pin versions in reproducible environments:
npm install -g droid@<VERSION>,droid update --version <VERSION>, orFACTORY_DROID_AUTO_UPDATE_ENABLED=false. - ✅ Watch cost and context with
/costand/context; compress long sessions with/compress. - ✅ Use worktrees (
--worktree) to run parallel sessions on one repo without file conflicts.
Don’t
- ❌ Don’t use
--skip-permissions-unsafeoutside disposable sandboxes — and remember command blocks apply even then. - ❌ Don’t paste secrets into
.factory/mcp.json, skills, hooks, or commits; Droid Shield only catches what it can scan. - ❌ Don’t expect
--auto highto clear anaskdecision indroid exec— one-shot runs cannot answer approval prompts. - ❌ Don’t mix unrelated work in one session, and don’t convert a marathon session into a Mission.
- ❌ Don’t expect BYOK parity: only Anthropic and OpenAI models via their official APIs are fully tested, and sub-30B-parameter models aren’t recommended for production agentic coding.
Quick Command Reference
| Command | Use |
|---|---|
droid | Start an interactive session in the current directory. |
droid "query" | Start with an opening prompt. |
droid -r / droid --resume <ID> | Resume the last session or a specific one. |
droid --fork <ID> | Fork a session into a new copy. |
droid --use-spec | Start in Spec Mode (plan before edits). |
droid --worktree [NAME] | Run in an isolated git worktree. |
droid exec "query" | Headless one-shot run (read-only by default). |
droid exec --auto <LEVEL> | Autonomy tiers: low, medium, high. |
droid exec -f <FILE> | Load the prompt from a file. |
droid exec -o json | Structured output (text, json, stream-json, stream-jsonrpc). |
droid exec --use-spec | Plan first, then execute. |
droid exec --mission --auto high | Run a Mission headlessly. |
droid search "query" | Search local session history. |
droid rules check | Validate permission rules and preview decisions. |
droid mcp add <NAME> <URL> --type http | Add an MCP server (also --type sse / stdio). |
droid mcp list | Show MCP server status. |
droid plugin install <PLUGIN> | Install a plugin. |
droid update --check | Check for a CLI update without installing. |
droid computer register <NAME> | Register this machine as a BYOM computer. |
| In-session command / key | Use |
|---|---|
/settings | Configure behavior, models, autonomy, output style. |
/model | Switch models mid-session (also Ctrl + N). |
/review | Start the local code review workflow. |
/sessions · /fork | List sessions / copy the current session. |
/skills · /droids · /hooks · /mcp | Manage skills, subagents, hooks, MCP servers. |
/missions | Open the Missions menu. |
/compress · /context · /cost | Compress context / show context usage / usage stats. |
Shift + Tab | Toggle Normal ↔ Spec Mode. |
Ctrl + L | Cycle autonomy levels. |
Ctrl + T | Toggle the Mission Control overlay. |
! | Bash mode: run a shell command without AI interpretation. |
Ctrl + O | Toggle the detailed transcript. |
? | Open the keyboard shortcut pane. |
Expected Outcomes
- A signed-in Droid session in your repo that maps the codebase before proposing reviewable diffs.
~/.factory/settings.jsonwith your model preference, autonomy default, permission rules, and Droid Shield enabled.- Spec Mode plans reviewed and approved before implementation, optionally saved as Markdown.
- Durable repo context through AGENTS.md, project skills, and custom droids, plus MCP servers and hooks wired in.
- Headless
droid execruns in CI at the lowest sufficient--autotier, with JSON output and non-zero exits treated as failures. - Missions that plan, delegate, and validate large multi-feature work under High autonomy.
- Sessions mirrored to the web via
cloudSessionSync, resumable locally withdroid --resume.
Reference
Sources & deeper reading
Official docs (facts and commands):
- Factory docs — LLM-friendly Markdown index
- Droid CLI quickstart · CLI reference · Settings
- Droid Exec (headless) · Autonomy levels · Spec Mode · Permission rules
- AGENTS.md · Skills · Custom droids · Hooks · MCP
- Custom models (BYOK) · Missions · Release notes
Community sources & tips:
- Factory Droid tutorial: Missions, skills, agents — Sid Bharath; pragmatic workflows: start with a read-only repo audit, keep AGENTS.md sharp, narrow the MCP surface
- Factory Droid: review and setup guide — Developers Digest; setup, model routing, and BYOK notes
Omitted areas (see docs): Factory App and web/mobile surfaces, Software Factory automations (triage, code review CI, QA, wiki, incident response), remote delegations (Slack/Linear/Jira), Python/TypeScript SDKs and REST API, enterprise deployment/SSO/telemetry, Droid Computers deep dive, image generation, output styles.