Coding agent boundaries
Goal: use coding help without letting an agent roam your whole repo unsupervised.
Best for: beginners using ChatGPT/Claude/Grok for code, or first steps with coding agents.
Coding agents are powerful and easy to over-trust. Boundaries: small diffs, tests or manual checks, no secrets in prompts, no production deploys from chat.
If you are brand new: prefer “explain + suggest patch” over “edit my whole project.”
Why beginners skip this
Coding help without a path allow-list feels fast until the agent edits files you never meant to touch. Boundaries are named paths and a stop on overreach—not “be careful.”
Habit this week (Asia/Shanghai): before one coding-agent run, write allowed paths and a forbid zone; date the first time you stop an overreach.
Step 1 — Minimal repro before edits
Paste the smallest code that shows the bug, plus expected vs actual. Ask for diagnosis first.
Goal: Diagnose only—no full rewrite.
Language: [lang]
Minimal code:
[paste]
Expected: …
Actual: …
Format: likely cause · 2 fix options · which files would change · risks
Example
Filled prompt
Bug: POST /api/session returns 500 after Tuesday deploy (Asia/Shanghai).
Boundary card first:
Allowed: src/auth/, tests/auth/
Forbidden: .env*, infra/, force-push, any production deploy command
Task: explain current failure in 5 bullets, then propose minimal diff on allowed paths only.
If a fix needs infra/, stop and ask—do not invent YAML.
What good output looks like
- Done boxes for “Coding agent boundaries” are explicit and checkable
- Allow-list tools only; never-do lines honored
- Stops before send/delete without human gate
- Pass/fail: Plan→Act one→Check visible for agents-coding-agent-boundaries
- Pass/fail dated (Asia/Shanghai) sits next to the artifact
Step 2 — Patch with a fence
Allow edits only in named files/functions. Require a short diff summary.
Apply the chosen fix ONLY to [file/function].
Show: diff summary · full updated function · how I test in 3 steps.
Do not touch other files.
Example
Filled prompt
Bug: flaky test test_session_refresh in CI only.
Boundary card first:
Allowed: tests/auth/, src/auth/session.ts
Forbidden: rewriting CI YAML, touching other packages, force-push
Task: explain flake hypotheses in 5 bullets, then minimal test-only fix on allowed paths.
Stop if you need infra/ — ask me.
What good output looks like
- Allow-list tools only; never-do lines honored
- Stops before send/delete without human gate
- Pass/fail: Plan→Act one→Check visible for agents-coding-agent-boundaries
- Done boxes for “Coding agent boundaries” are explicit and checkable
Step 3 — Red lines for coding agents
Never: paste API keys, grant whole-home access, auto-commit to main, run unknown curl scripts. Prefer a git branch.
Rewrite my coding-agent rules in ≤12 bullets for a beginner.
Include: secrets · scope · tests · git · when to stop and ask.
Example
Filled prompt
Agent asked mid-run to widen from /src/auth to the whole monorepo “for cleanup.”
Draft my refusal + re-approval script: stay in allow-list; new paths need a new written OK.
What good output looks like
- Restates allowed/forbidden paths before any diff
- Explains the 500 in bullets that match the stack you know
- Patch touches only listed paths; stops if infra is required
- No .env contents, no force-push advice
Save this card
Card: allowed paths · forbid zone · stop on overreach. “Be careful” is not a boundary.
1. What I shipped: ___ 2. What I refused: ___ 3. What I will never-do again: ___ (date: Asia/Shanghai)
- [ ] Tools/writes paused
- [ ] Refuse-line dated
- [ ] Artifact path saved
- [ ] Next link chosen (or stop)
Before you start
Write Done (checkboxes) and the human gate on paper before any run for “use coding help without letting an agent.” Allow-list tools; leave send/delete off. Guide: agents-coding-agent-boundaries. If you only have a blank practice box, stop and fetch the real job first.
- Goal in one line: ___
- Allowed tools: ___
- Forbidden: ___
- Human approve needed for: ___
How to use this week
Write a one-page boundary card: allowed paths, forbidden paths, no force-push, no .env, no production deploys. Paste it at the top of every coding-agent chat. Run one real PR only inside that box. Ship the artifact out of chat (doc/PR/note) so the week leaves a file, not only a thread—date it Asia/Shanghai.
Allowed paths list
Paste the allow-list at the top of every coding agent job. Widening mid-run requires a new approval.
Keep it real
Run this guide’s Practice now on work you will actually ship this week—not a fictional scenario. Dated notes beat perfect theory.
Ship the practice
Close the tab only after Practice now is done on a real artifact.
Do not bookmark-only
Finish Practice now, then tick this guide on your path. Titles unread are not skills.
Close the loop
After Practice now, write one line: what you will refuse next time. That line is the habit.
Red flag
Writable paths include secrets or the whole repo; patching without a minimal repro; agent pushes remote without asking—hard stop.
Pitfalls
| Pitfall | Fix |
|---|---|
| “Fix the repo” with no repro | Minimal failing example first |
| Accepting huge unrelated refactors | Fence the file list |
| Pastoring .env into the chat | Redact secrets |
Example
Filled prompt
Temptation: skip the habit for agents-coding-agent-boundaries to “save five minutes.”
Job still: use coding help without letting an agent
Do the smallest correct pass: Done visible · one checkable artifact · Unknowns labeled [?].
Boundaries: draft only; no silent send; no invented metrics.
Return: the artifact + the refuse-line you said aloud.
What good output looks like
- Names the shortcut you refused (specific to agents-coding-agent-boundaries)
- Still delivers a checkable artifact for “use coding help without letting an agent”
- Unknowns labeled; draft-only respected
- Pass/fail: refuse-line written and dated (agents-coding-agent-boundaries #4)
Practice now
Live card: run one agent checklist item on a real job for “Coding agent boundaries”—artifact path on Save (Asia/Shanghai).
Today: open one live bug. Paste your boundary card first. Ask for an explain-then-minimal-diff on named files only. Reject any patch that touches a path you did not list.
Today card (copy) — agents-coding-agent-boundaries: 1. Artifact I will produce: ___ 2. Pass/fail check: ___ 3. Refuse-line if tempted to skip verify/send: ___ (date: Asia/Shanghai) 4. One never-do from this guide: ___
- [ ] Artifact path written
- [ ] Refuse example would say "yes"
- [ ] Dated Asia/Shanghai
One sentence takeaway
Name allowed paths before a coding agent touches the repo; stop on overreach. This week: log one dated stop (Asia/Shanghai).
Next
Minimal repro first · Failure modes and retries · Define done and permissions · Human-in-the-loop checkpoints · Blast radius
Pair with today: open the first Next link (code-minimal-repro-first) only after you dated a refuse-line for this guide (Asia/Shanghai).
编程智能体的边界
目标: 用好编程帮助,又不让智能体在无人看管时逛完整仓库。
适合: 用 ChatGPT/Claude/Grok 问代码的初学者,或第一次接触编程智能体的人。
编程智能体很强,也很容易被过度信任。边界:改动要小、要有测试或手工检查、提示词里不放密钥、不从聊天直接部署生产。
若你完全新手:优先「解释 + 建议补丁」,而不是「改我整个项目」。
为什么新手跳过
没有路径白名单的编程帮助看起来快,直到 agent 改到你从没打算动的文件。边界是具名路径与越界即停——不是口头「小心点」。
本周习惯(Asia/Shanghai):开跑前写清允许路径与禁止区;第一次拦下越界时写上日期。
步骤 1——先最小复现,再谈修改
贴出能暴露问题的最小代码,加上期望 vs 实际。先要求诊断。
目标:只诊断——不要整文件重写。
语言:[语言]
最小代码:
[粘贴]
期望:…
实际:…
格式:可能原因 · 2 种修法 · 会动哪些文件 · 风险
实例
填好的提示词
Bug:周二部署后 POST /api/session 返回 500(Asia/Shanghai)。
先贴边界卡:
允许:src/auth/、tests/auth/
禁止:.env*、infra/、force-push、任何生产部署命令
任务:用 5 条解释当前失败,再只在允许路径上给最小 diff。
如果需要改 infra/ 就停下询问——不要编 YAML。
像样的输出大概长这样
- 原因说得清楚
- 给小修法
- 不重写无关模块
- 贴合这个填例——不是空泛打气
- 相关则拒绝编造事实或静默发送
步骤 2——打补丁要设围栏
只允许改指定文件/函数。要求简短 diff 摘要。
只把选定修法应用到 [文件/函数]。
展示:diff 摘要 · 更新后的完整函数 · 我如何用 3 步测试。
不要动其他文件。
实例
填好的提示词
Bug:CI 里 test_session_refresh 不稳定。
先贴边界卡:
允许:tests/auth/、src/auth/session.ts
禁止:重写 CI YAML、动其他包、force-push
任务:用 5 条假设解释偶发失败,再只在允许路径上做最小测试修复。
如果需要动 infra/ 就停下问我。
像样的输出大概长这样
- 范围被遵守
- 测试步骤初学者能跑
- 没有顺手大重构
- 贴合这个填例——不是空泛打气
- 相关则拒绝编造事实或静默发送
步骤 3——编程智能体红线
绝不:粘贴 API 密钥、授权整个用户目录、自动提交到 main、跑来路不明的脚本。优先新建 git 分支。
把我的编程智能体规则改写成 ≤12 条,给初学者看。
包含:密钥 · 范围 · 测试 · git · 何时停下来问我。
实例
填好的提示词
场景:真实工作(打开活材料)。
Agent 中途要求把范围从 /src/auth 扩到整个 monorepo「顺便清理」。
写拒绝回复:重申边界卡、允许的下一步、若越界就停。
只出草稿,不执行扩权。
约束:不编造事实;发送/删除前停下;未知处标「未知」。
像样的输出大概长这样
- 可执行条目
- 提到用分支而不是 main
- 删除/迁移要停问
- 贴合这个填例——不是空泛打气
- 相关则拒绝编造事实或静默发送
保存这张卡
卡片:允许路径 · 禁止区 · 越界即停。「小心点」不算边界。
开始前
打开你真正会用的账号/项目。准备好与「编程智能体的边界」相关的真实材料(不要空白练习框)。
默认姿态:在人确认发送/写入之前只出草稿。授予新工具前,先写一条带日期的拒做句(Asia/Shanghai)。
- 一句话目标:___
- 允许的工具:___
- 禁止:___
- 需要人批准:___
本周怎么用
本周只允许智能体改白名单路径;先最小复现再补丁。密钥与生产配置永不进可写范围。合入前能三句话讲清改了哪些路径。过/不过注明日期(Asia/Shanghai)。
周中代价检查:若明天丢掉这个习惯,24 小时内会坏在哪?写一行(Asia/Shanghai)。
允许路径列表
每次代码智能体任务顶部粘贴允许列表。运行中扩大需要重新批准。
保持真实
用本周真会交付的工作做「现在就练一次」——不要虚构场景。带日期的笔记胜过完美理论。
把练习做完
实卡:用「编程智能体的边界」对真实任务跑一条智能体清单——产物路径进 Save(Asia/Shanghai)。
今天把「编程智能体的边界」练完:真实材料、过/不过、一句永不做。注明日期(Asia/Shanghai)。
不要只收藏
做完「现在就练一次」,再在路径上打勾。没练过的标题不是技能。
闭环
「现在就练一次」后写一行:下次你要拒绝什么。那一行才是习惯。
红旗
可写范围含 .env 或整仓;未复现就大面积重构。模型要「先推远程」——拒绝。卡上写不清就不继续——先补检查项再跑。
常见坑
| 坑 | 改法 |
|---|---|
| 「修仓库」却没有复现 | 先最小失败例子 |
| 接受巨大无关重构 | 围栏文件列表 |
| 把 .env 贴进聊天 | 脱敏 |
实例
填好的提示词
任务:use coding help without letting an
场景要点:Agent 运行前 Done/门闸写好;练习编号 4/4。
边界:仅草稿;未知 [?];禁止悄悄发送;禁止编造指标。
返回:可检查产出 + 过/不过理由一行。
像样的输出大概长这样
- 约束贴着「编程智能体的边界」与 agents-coding-agent-boundaries
- 未知标 [?];不编造负责人/数字
- 不可逆动作前停下
- 一分钟内能打过/不过(agents-coding-agent-boundaries #4)
现在就练一次
今天设一条允许路径列表,在围栏内修一个小缺陷。过/不过与永不做注明日期(Asia/Shanghai)。只收藏标题算失败。
今日卡片(可复制)— agents-coding-agent-boundaries: 1. 我要产出的成品:___ 2. 通过/失败标准:___ 3. 若想跳过核验/发送的拒做句:___(日期:Asia/Shanghai) 4. 本篇一条永不做:___
- [ ] 成品路径已写
- [ ] 拒做例句会说「可以」
- [ ] 已标注 Asia/Shanghai 日期
一句话带走
编程 agent 动仓库前点名允许路径;越界即停。本周记下一次带日期的拦停。
下一步
先做最小复现 · 失败模式与重试 · 定义完成与权限 · 人在回路检查点 · 爆炸半径
今日搭配:先为本篇写上拒做句日期(Asia/Shanghai),再打开下一步里的第一篇(code-minimal-repro-first)。
← Back to home · Learn · Tools · Compare · Start