DeepSeek Reasonix in action: Build an AI programming agent at zero cost (30-minute tutorial)
From installation to practice, master the Cache-First low-cost and Skills automation of DeepSeek's native programming agent in 30 minutes
Beginner · 30 min · May 25, 2026
Tutorial Objectives
Complete the installation, configuration and practice of DeepSeek Reasonix in 30 minutes. You will learn to use this open source AI programming agent to automatically fix bugs, write functions, and run tests - and because of DeepSeek's prefix-cache mechanism, the cost of long-session input tokens is reduced to 1/5 of the original.
What will you build?
- AI Programming Agent Environment: Terminal native TUI, start anytime, anywhere
npx reasonix code - Cache-first long sessions: 94% cache hit, append-only loops keep costs extremely low
- Skills Automation Script: Use Markdown to write reusable Agent scripts
Preparation list
- DeepSeek API Key (platform.deepseek.com registered to obtain, billed by volume)
- Node.js ≥ 22 (macOS/Linux/Windows are acceptable)
- An existing code project (or create a new demo project to practice)
Overall architecture
Reasonix's loop is append-only: messages and tool results are always appended to the end, and the history is never modified. This keeps DeepSeek's prefix-cache hit after every tool invocation.
| Module | Input | Output | Estimated time |
|---|---|---|---|
| Environment installation | API Key + Node.js | Reasonix ready | 5 minutes |
| First Session | Natural Language Requirements | AI Generated Code | 10 Minutes |
| Skills configuration | Markdown scripts | Reusable automation | 10 minutes |
| MCP Extensions | External Tools Server | Enhanced Toolset | 5 Minutes |
Step 1: Install Reasonix and configure API Key
Reasonix does not require global installation. In Node.js ≥ 22 environment, one line of commands can start:
# 进入你的项目目录
cd /path/to/your-project
# 直接启动(首次运行会自动引导配置 API Key)
npx reasonix code首次运行会弹出内置向导,粘贴你的 DeepSeek API Key 即可。这个 Key 会保存在 ~/.reasonix/config.json 中,后续无需重复配置。
提示:DeepSeek API 的计费极低——输入 $0.07/Mtok,命中缓存仅 $0.014/Mtok。Reasonix 的 append-only 循环设计让长会话缓存命中率保持在 90% 以上,实际成本远低于同类工具。
配置完成后,你可以用以下命令检查状态:
# 查看配置
cat ~/.reasonix/config.json
# 查看帮助
npx reasonix --helpReasonix 也提供桌面端(Tauri 原生客户端),自带 Node runtime、多 tab 会话和实时 cost/cache/token 表盘,适合不想碰命令行的用户。但本教程聚焦终端版——它更轻量、更适合 CI/CD 集成。
第 2 步:首次 AI 编程会话
启动 Reasonix 后,你会进入一个终端 TUI 界面。它不是一个 IDE 插件——diff 留给 git diff,文件树留给 ls,终端本身就是工作面板。
基础交互
进入会话后,直接用自然语言描述你的需求。Reasonix 默认使用 DeepSeek V4-Flash(快速且低成本),复杂任务可以用 /pro 切到 V4-Pro:
# 日常迭代用 Flash(默认)
> 帮我把这个 Python 脚本里的硬编码路径改成配置文件读取
# 复杂重构切 Pro
/pro
> 重构这个模块,把单体函数拆成职责单一的三个类,保持测试通过Reasonix 会自动读取项目文件、执行 shell 命令、修改代码。所有操作沙箱化到启动目录,不会越权访问。
双档位策略
| 档位 | 触发方式 | 适用场景 | 成本 |
|---|---|---|---|
| V4-Flash | 默认 | 日常修 bug、小功能、代码审查 | 极低 |
| V4-Pro | /pro 命令 | 复杂重构、架构设计、多文件联动 | 中等 |
| 全 Pro | /preset max | 整轮对话用 Pro | 较高 |
实战示例:让 Reasonix 修一个 bug
假设你的项目有一个 utils.py 文件,其中 parse_config 函数在文件不存在时直接崩溃:
> utils.py 的 parse_config 函数在配置文件不存在时应该返回默认值而不是崩溃,帮我修复
Reasonix 会:
- 读取
utils.py,定位parse_config函数 - 分析错误原因
- 生成修复代码(添加 try/except 或 os.path.exists 检查)
- 询问你是否确认修改
确认后,Reasonix 应用修改,你可以用 git diff 查看变更。
第 3 步:用 Skills 编排可复用自动化
Skills 是 Reasonix 最强大的功能之一——用 Markdown 编写 Agent 行为剧本,放在 .reasonix/skills/ 目录下即可。
创建一个 Code Review Skill
在项目根目录创建 .reasonix/skills/code-review.md:
---
name: code-review
description: 代码审查:检查安全性、性能和可维护性
runAs: subagent
allowed-tools: [read, grep, glob]
---
## 任务
对当前项目的变更文件进行代码审查。
## 检查维度
1. **安全性**:是否有 SQL 注入、XSS、路径遍历风险
2. **性能**:是否有 N+1 查询、不必要的循环、大对象拷贝
3. **可维护性**:函数是否过长(>30 行)、命名是否清晰
## 输出格式
生成一份 markdown 报告,按严重程度排序。然后在 Reasonix 会话中直接调用:
/skill code-review
``__TOK28 __read`, `grep`, `glob` Three read-only tools - will not modify any code, ensuring the independence of the review.
### More Skill Examples
You can create various Skills:
- **Generate CHANGELOG**: Read git log and automatically generate version update log
- **Run Test + Fix**: Run the test first and automatically fix the code for failed use cases
- **API document generation**: scan routing files and generate OpenAPI documents
Skills are plain text Markdown that can be submitted to the git repository, and team members share the same set of Agent scripts.
## Step 4: Access the MCP extension tool chain
Reasonix provides first-class citizen support for MCP (Model Context Protocol) and supports three transmission protocols: stdio, SSE, and Streamable HTTP.
### Mount an MCP Server
```bash
# 挂载 GitHub MCP Server
npx reasonix code --mcp "github=npx @anthropic/mcp-server-github"
# 挂载文件系统 MCP Server
npx reasonix code --mcp "fs=npx @anthropic/mcp-server-filesystem /path/to/allowed/dir"也可以在 ~/.reasonix/config.json 中持久化配置:
{
"mcp": {
"github": {
"command": "npx",
"args": ["@anthropic/mcp-server-github"]
},
"filesystem": {
"command": "npx",
"args": ["@anthropic/mcp-server-filesystem", "/home/user/projects"]
}
}
}每个 MCP server 的工具会以前缀合并进 Reasonix 统一的工具 registry,对模型完全透明。挂载 GitHub MCP 后,你可以直接说"帮我创建一个 PR"——Reasonix 会自动调用 GitHub 工具完成操作。
常见问题排查(FAQ)
Q1:npx reasonix code 报错 "Node version too old"?
升级 Node.js 到 ≥ 22。用 node -v 检查版本,推荐用 nvm 管理:
nvm install 22
nvm use 22Q2:API Key 配置后仍然提示认证失败?
检查 ~/.reasonix/config.json 中 apiKey 字段是否正确。也可以设置环境变量:
export DEEPSEEK_API_KEY="sk-xxxxxxxxxxxxxxxx"Q3:长会话 token 成本真的能降到 1/5?
是的。Reasonix 的 append-only 循环设计专门适配 DeepSeek 的 prefix-cache 机制:消息历史不重排、不基于 marker 压缩,缓存前缀在每次工具调用后保持稳定。实测长会话(50+ 轮)缓存命中率 90%+,输入 token 成本降为原来的 1/5~1/4。
Q4:Reasonix 和 Claude Code 有什么区别?
Claude Code 是 Anthropic 生态的编程 Agent,依赖 Claude API。Reasonix 是 DeepSeek 原生设计,核心优势在于极低成本(DeepSeek 的缓存定价 + Reasonix 的 Cache-First 循环)和终端优先的轻量设计。两者可以互补使用——简单任务用 Reasonix(省钱),复杂架构讨论用 Claude Code(推理更强)。
工具词条(触发工具悬浮卡)
正文中自然出现的工具名,平台侧会匹配已维护 tools 库生成 hover-card:
DeepSeek、Reasonix、Claude Code、Node.js
Reference video/material
Internal link guidance
- Someone has successfully practiced it: 他用 Claude Code + AWS 搭建 AI SaaS,3个月月入 $12,000
- Someone has successfully practiced it: Claude Code 48小时创业:一人+29美元月费,3个月做到月入$9,000
DeepSeek topic related tutorials
Related tutorials
AI Coding Agents Complete Guide: Setup, Security, Workflow & Case Studies
If you are researching AI coding agents and want to know which one to use, how to set it up safely, and what real developers are building with them — this hub organizes every tutorial, case study, and comparison we have published. Start with the decision guide below to find the right path for your skill level and goals.
AI Micro SaaS FAQ: 25 Common Questions Answered (2026)
Everything you need to know about building and profiting from AI Micro SaaS products. This FAQ covers idea generation, tech stack choices, pricing strategy, marketing on a $0 budget, legal considerations, and scaling from $100 to $10K MRR. Based on real case studies and data from successful solo builders using Claude Code, Cursor, and other AI coding tools.
Topic hub
AI Coding Tools Hub (2026)
From Copilot pricing changes to Claude Code + DeepSeek cost-saving setups—one place to compare tools, read explainers, and follow tutorials.
Explore AI Coding Tools Hub (2026) →Monetization angle
How can you make money from this trend?
WayToClawEarn focuses on verified earn playbooks—not just news. Start from these cases.
DeepSeek + Claude Code Micro SaaS
Run multiple small products on cheap inference
Claude Code bug bounty
Productize agent skills into security services