Skip to content

Droid 完全指南

Factory Droid 是由 Factory.ai 打造的企业级 AI 编程助手,在 Terminal-Bench 基准测试中拿下了 58.75% 的得分,超越了 Opus 4.1 和 GPT-5。它直接在终端里运行,能帮你写代码、跑命令、做代码审查,还能对接 Jira、Notion、Slack 等团队工具。

快速上手#

安装配置#

Terminal window
# macOS/Linux 一键安装
curl -fsSL https://app.factory.ai/cli | sh
# Linux 用户需要安装 xdg-utils
sudo apt-get install xdg-utils # Debian/Ubuntu
Terminal window
# Windows PowerShell
iex "& { $(irm https://app.factory.ai/cli) }"

配置 API Key:

Terminal window
# 从 https://app.factory.ai/settings/api-keys 获取 API Key
export FACTORY_API_KEY='fk-your-api-key' # 加到 ~/.zshrc 或 ~/.bashrc

启动:

Terminal window
cd your-project-folder
droid

进入全屏终端界面后,如果是首次使用会提示通过浏览器登录 Factory 账号。注意国内手机号无法注册,只能使用国外手机号,这一步比较麻烦,得花时间找平台,还得花钱买短信服务。 建议直接去闲鱼买一个 API Key,价格也不贵,几块钱就有几千万的token,可以多囤一些,最近好像每天都在涨价😂。 可以通过这个链接下载 droid 的 API Key 管理工具 Zdroid,把在闲鱼上买的key添加进去,最后终端输入 droid 愉快的用起来!

基础用法#

Terminal window
# 进入交互模式
droid
# 带问题进入交互模式
droid "explain this project"
# 单次执行(不进入交互模式)
droid exec "summarize src/auth"
# 从文件读取 prompt
droid exec -f prompt.md
# 管道输入
git diff | droid exec "draft release notes"
# 恢复已有会话
droid exec -s session-123 "continue"

快捷键速查#

操作说明
Enter发送消息
Shift + Enter换行
Shift + Tab切换模式(普通/Spec 模式)
!切换 Bash 模式(直接执行 shell 命令)
Esc退出 Bash 模式
?查看所有快捷键
Ctrl + C退出

核心功能详解#

AGENTS.md - 让 AI 懂你的项目#

和 Claude Code 的 CLAUDE.md 类似,Droid 用 AGENTS.md 来理解项目上下文。区别在于:AGENTS.md 是跨工具标准,Cursor、Aider、Gemini CLI、Zed 等都支持。

创建方式:

在项目根目录新建 AGENTS.md

# MyProject
后端 API 服务,使用 TypeScript + Express。
## Core Commands
- Type-check: `pnpm check`
- Test: `pnpm test --run`
- Dev server: `pnpm dev`
- Build: `pnpm build`
## Project Layout
├─ src/ → 源代码
├─ tests/ → 测试文件
├─ config/ → 配置文件
## Conventions
- TypeScript strict mode,单引号,尾逗号
- 用 interfaces 定义公共 API
- 修 bug 前先写失败测试
- PR 需要通过 lint + type check + 测试

最佳实践:

文件发现顺序:

  1. 当前目录的 AGENTS.md
  2. 向上查找到 repo 根目录
  3. 正在编辑文件所在目录的 AGENTS.md
  4. 个人全局配置:~/.factory/AGENTS.md

Spec Mode - 大需求必备#

Spec Mode 是 Droid 的杀手锏功能。你只需用 4-6 句话描述需求,Droid 会自动生成详细的技术方案,确认后才开始改代码

激活方式:Shift + Tab 切换到 Spec Mode

工作流程:

你的输入 → Droid 生成规格说明 → 你审查确认 → Droid 实现

示例:

[Spec Mode]
添加用户数据导出功能。
导出为 ZIP 文件,包含用户资料、帖子和上传的文件。
完成后发邮件通知。需要符合 GDPR 要求。
支持最大 2GB 的账户数据。

Droid 会生成:

确认后的自主级别选项:

选项说明
Proceed批准方案,保持手动确认每个修改
Low允许编辑文件和只读命令
Medium允许可逆操作(安装依赖、本地 commit 等)
High允许所有操作(git push、部署等)
Keep iterating继续完善方案

🔶 提示: 大需求用 Spec Mode 能省不少时间和 token,避免 AI 走弯路。

自主级别(Autonomy Levels)#

droid exec 支持分级自主控制:

Terminal window
# 默认:只读分析
droid exec "Analyze the auth system and create a plan"
# Low:安全编辑
droid exec --auto low "Add JSDoc comments to all functions"
# Medium:开发工作
droid exec --auto medium "Install deps, run tests, fix issues"
# High:CI/CD 场景
droid exec --auto high "Run tests, commit, and push changes"
# 完全放开(仅限沙箱环境!)
droid exec --skip-permissions-unsafe "..."

🔶 警告: --skip-permissions-unsafe 移除所有安全检查,只在隔离的 Docker 容器中使用

斜杠命令#

交互模式下可用的命令:

命令说明
/help查看所有命令
/model切换 AI 模型
/settings配置 Droid 行为和偏好
/mcp管理 MCP 插件
/new开始新会话
/sessions查看历史会话
/compress压缩当前会话(保留摘要)
/cost查看 token 用量
/review启动代码审查工作流
/droids管理自定义 Droid
/skills管理和调用 Skills

MCP 插件#

MCP (Model Context Protocol) 让 Droid 能连接外部数据源和工具。

Terminal window
# 打开 MCP 管理界面
/mcp
# 从注册表添加(推荐)
# 选择 "Add from Registry",有 40+ 预配置的服务器
# 命令行添加 HTTP 服务器
droid mcp add linear https://mcp.linear.app/mcp --type http
# 添加 stdio 服务器
droid mcp add myserver "node /path/to/server.js"
# 删除
droid mcp remove linear

内置集成(Factory Dashboard 配置):

模型选择#

Terminal window
# 交互模式切换
/model
# 命令行指定
droid exec -m claude-sonnet-4-5-20250929 "review this code"
# Spec Mode 用不同模型规划
droid exec --spec-model claude-sonnet-4-5-20250929 --use-spec "add user profiles"

可用模型:

模型 ID名称推理支持
claude-opus-4-5-20251101Claude Opus 4.5(默认)Off/Low/Medium/High
gpt-5.1-codex-maxGPT-5.1-Codex-MaxLow/Medium/High/Extra High
claude-sonnet-4-5-20250929Claude Sonnet 4.5Off/Low/Medium/High
gemini-3-pro-previewGemini 3 ProLow/High
glm-4.6Droid Core (GLM-4.6)None

也支持 BYOK(Bring Your Own Key),使用格式:custom:<alias>

实战案例#

探索代码库#

Terminal window
droid "analyze this codebase and explain the overall architecture"
droid "what technologies and frameworks does this project use?"
droid "where are the main entry points and how is testing set up?"

实现功能#

Terminal window
# 简单描述,让 Droid 理解并实现
droid "add comprehensive error handling to the payment processor in src/payments/processor.ts. Catch gateway timeouts and retry up to 3 times with exponential backoff. Similar retry logic exists in src/notifications/sender.ts. Run the payment integration tests to verify it works."

修复 Bug#

Terminal window
# 带上下文的 bug 描述
droid "Users report file uploads fail randomly. Error in browser console: 'Network timeout'. Upload logic is in src/upload/handler.ts. Check for timeout handling."

代码审查#

Terminal window
# 审查未提交的修改
droid "review my uncommitted changes and suggest improvements before I commit"
# 用 git diff 审查
droid "look at git diff and review these changes for security issues"

重构#

Terminal window
# 带约束的重构
droid "extract the email sending logic into a separate service class. Keep the same interfaces but make it testable in isolation."

对接外部工具#

Terminal window
# 从 Jira ticket 实现功能
droid "implement the feature described in this Jira ticket: https://company.atlassian.net/browse/PROJ-123"
# 从 Notion 文档获取需求
droid "build the API endpoints based on the spec in this Notion page: https://notion.so/..."

Git 工作流#

Terminal window
# 智能 commit
droid "create a well-structured commit with a descriptive message following our team conventions"
# 分析历史
droid "analyze the last few commits and identify any potential issues or patterns"
# 找历史代码
droid "find the commit that introduced the caching mechanism and explain how it works"

CI/CD 集成#

# GitHub Actions 示例
- name: Run Droid Analysis
env:
FACTORY_API_KEY: ${{ secrets.FACTORY_API_KEY }}
run: |
droid exec --auto medium -f .github/prompts/deploy.md

进阶技巧#

写好 Prompt 的几个要点#

好的写法:

Terminal window
# 明确目标、指定文件、说明验证方式
droid "Add comprehensive error handling to the payment processor in src/payments/processor.ts. Catch gateway timeouts and retry up to 3 times with exponential backoff. Run the payment integration tests to verify."

🔶 避免的写法:

Terminal window
# 太模糊
droid "make the app better"
droid "fix the database"
droid "can you help with the frontend?"

管理上下文#

大功能拆分#

阶段 1:

Terminal window
droid "implement user data export backend API and job processing. Focus only on the server-side functionality, not the UI yet."

阶段 2:

Terminal window
droid "add the frontend UI for data export using the API from Phase 1. Include progress indicators and download management."

会话管理#

和 Claude Code 比有啥区别?#

特性DroidClaude Code
上下文文件AGENTS.md(跨工具标准)CLAUDE.md(专用)
Spec Mode✅ 内置❌ 无
自主级别4 级(Low/Medium/High + unsafe)普通/YOLO 两档
企业集成Jira/Notion/Slack 等内置需要 MCP 配置
MCP 支持
模型选择多模型 + BYOKAnthropic 模型为主
定价API 按量API 按量

选择建议:

常见问题#

Token 消耗太快?#

几个省 token 的办法:

担心代码被改坏?#

Droid 有完整的保护机制:

让 Droid 更懂项目?#

写在最后#

Droid 的核心价值:

适合这些人:

上手建议:

  1. 先拿小项目试试基础功能
  2. 好好写 AGENTS.md
  3. 大需求用 Spec Mode
  4. 逐步尝试 MCP 和企业集成

装上就能用,终端里的 AI 搭档,试试就知道有多方便了 🚀