记录自用的agent配置(keep updated)
Skills && Plugins#
Skills管理工具#
Great Skills && Plugins#
- Ponytail(Plugin) - 节省你的tokens
MCP#
- Context7 - 给agent提供最新官方文档
- Tavily - 让agent能够搜索网络信息
- Playwright - Web自动化
- Shadcn - 提供前端组件库
Setup#
OpenCode#
以下是opencode配置文件,会不断更新,主要考虑了安全性,然后暂时只做了一些基础配置.
自用的opencode.jsonc(点击展开)
1{
2 "$schema": "https://opencode.ai/config.json",//作用:为VScode等编辑工具提供自动补全和校验等 不影响opencode实际使用功能
3 "autoupdate": true,
4 "small_model": "deepseek/deepseek-v4-flash",
5 "default_agent": "plan",//先明确需求再操作文件
6 "permission": {
7 "read": {
8 "*":"allow",
9 ".env":"deny",
10 ".env/**":"deny",
11 "/.env/api_keys.txt":"deny",
12 ".env/keys.txt":"deny",
13 ".env.example":"allow",
14 "*.pem":"deny",
15 "*.key":"deny",
16 "keys/**":"deny"
17 },
18 "external_directory":"ask",//外部目录操作需要确认,自行审查命令
19 "bash": {
20 "*": "ask",
21 "ls *": "allow",
22 "wc *": "allow",
23 "pwd": "allow",
24 "echo *": "allow",
25 "which *": "allow",
26 "git status *": "allow",
27 "git diff *": "allow",
28 "git log *": "allow",
29 "git show *": "allow",
30 "git branch *": "allow",
31 "npm test": "allow",
32 "npm run lint": "allow",
33 "npm run build": "allow",
34 "pytest *": "allow",
35 "go test *": "allow",
36 "cargo test *": "allow",
37 "rm -rf *": "deny",
38 "rm -fr *": "deny",
39 "sudo *": "deny",
40 "curl * | *": "deny",
41 "wget * | *": "deny"
42 }
43 },
44 "plugin": [
45 "opencode-supermemory",
46 "@dietrichgebert/ponytail"
47 ],
48 "compaction": {
49 "auto": true,
50 "prune": true,
51 "reserved": 10000
52 },
53 "watcher": {
54 "ignore": ["node_modules/**", ".git/**", "dist/**", "build/**", "*.log", ".env/**", "keys/**"]
55 },
56 "lsp": true,
57 "formatter": true,
58 "shell": "zsh",//如果是windows环境,需要修改为powershell
59 "agent": {
60 "code-reviewer": {
61 "description": "Reviews code for best practices and potential issues",
62 "model": "deepseek/deepseek-v4-flash",
63 "prompt": "You are a code reviewer. Focus on security, performance, and maintainability.",
64 "permission": {
65 "write": "deny",
66 "edit": "deny"
67 },
68 "steps": 15
69 },
70 "build": {
71 "permission": {
72 "bash": {
73 "*": "ask",
74 "git status *": "allow",
75 "git diff *": "allow",
76 "git log *": "allow",
77 "git show *": "allow",
78 "git branch *": "allow",
79 "git push *": "deny",
80 "git reset --hard *": "deny"
81 }
82 }
83 }
84 },
85 "command": {//自定义命令,重复性prompt
86 "clear": {
87 "template": "清理上述过程中临时产生并且没有用处的文件,停止因为临时测试而启动的本地服务.最后检查各个状态是否正常,若不正常,提醒我或者直接修复.最终目的是保持系统和项目环境干净!所以请不要产生其他负面影响!",
88 "description": "try to keep your project and system clean",
89 "agent": "build",
90 "model": "deepseek/deepseek-v4-flash",
91 "subtask": true
92 },
93 "cr": {
94 "template": "用 code-reviewer 视角审视本次会话最近的改动(git diff 范围),重点:安全漏洞、性能问题、可维护性、可测试性。给出具体行号和建议,不要泛泛而谈。",
95 "description": "Code-review on recent changes (renamed to avoid shadowing built-in /review)",
96 "agent": "code-reviewer"
97 },
98 "test": {
99 "template": "识别项目测试命令(查 package.json / pyproject.toml / go.mod / Cargo.toml 等),运行测试套件。如果失败,分析首个失败 case 的根因。",
100 "description": "Run project test suite (auto-detect)",
101 "agent": "build",
102 "model": "deepseek/deepseek-v4-flash",
103 "subtask": true
104 }
105 },
106 "mcp": {//MCP配置
107 "playwright": {
108 "type": "local",
109 "command": [
110 "npx",
111 "-y",
112 "@playwright/mcp"
113 ],
114 "enabled": true,
115 "environment": {
116 "PLAYWRIGHT_MCP_HEADLESS": "true"
117 }
118 },
119 "context7": {
120 "type": "local",
121 "command": [
122 "npx",
123 "-y",
124 "@upstash/context7-mcp"
125 ],
126 "enabled": true,
127 "environment": {
128 "CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"
129 }
130 },
131 "tavily": {
132 "type": "local",
133 "command": [
134 "npx",
135 "-y",
136 "tavily-mcp"
137 ],
138 "enabled": true,
139 "environment": {
140 "TAVILY_API_KEY": "{env:TAVILY_API_KEY}"
141 }
142 }
143 }
144}配置方式:
将 opencode.jsonc 放到项目根目录或OpenCode配置目录(~/.config/opencode/)即可生效:
1# 项目级配置
2cp opencode.jsonc /path/to/your/project/
3
4# 全局配置(推荐)
5mkdir -p ~/.config/opencode && cp opencode.jsonc ~/.config/opencode/