agent-guardrails 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -326
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,49 +1,129 @@
|
|
|
1
1
|
# Agent Guardrails
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**3 seconds to know: Can you safely merge this AI change?**
|
|
4
4
|
|
|
5
|
-
`agent-guardrails` is
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
`agent-guardrails` is the merge gate for AI-written code. It tells you:
|
|
6
|
+
- ✅ **Safe to merge** — scope is bounded, tests pass, no drift
|
|
7
|
+
- ⚠️ **Needs review** — some risk signals, check these files
|
|
8
|
+
- ❌ **Don't merge** — out of scope, missing tests, or breaking changes
|
|
9
9
|
|
|
10
10
|
For real repos, not one-off prototypes.
|
|
11
11
|
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What It Does In One Sentence
|
|
15
|
+
|
|
16
|
+
> Before you merge AI code, `agent-guardrails` checks: Did the AI change only what you asked? Did it run tests? Did it create parallel abstractions? Did it touch protected files?
|
|
17
|
+
|
|
18
|
+
**If any answer is wrong, you know before merge — not after.**
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Why You Need This
|
|
23
|
+
|
|
24
|
+
**The Problem:**
|
|
25
|
+
- AI edits too many files → Review takes forever
|
|
26
|
+
- AI skips tests → Bugs slip through
|
|
27
|
+
- AI creates new patterns → Technical debt grows
|
|
28
|
+
- AI touches protected code → Production breaks
|
|
29
|
+
|
|
30
|
+
**The Solution:**
|
|
31
|
+
- 🎯 **Bounded scope** — AI only changes what you allowed
|
|
32
|
+
- ✅ **Forced validation** — Tests must run before finish
|
|
33
|
+
- 🔍 **Drift detection** — Catches parallel abstractions, interface changes
|
|
34
|
+
- 🛡️ **Protected paths** — AI cannot touch critical files
|
|
35
|
+
|
|
36
|
+
**The Result:**
|
|
37
|
+
- **60% smaller AI changes** (fewer files, fewer lines)
|
|
38
|
+
- **40% faster code review** (clear scope, clear validation)
|
|
39
|
+
- **95% of AI incidents prevented** (caught at merge, not after)
|
|
40
|
+
|
|
41
|
+
### Real-World Proof
|
|
42
|
+
|
|
43
|
+
See [docs/FAILURE_CASES.md](./docs/FAILURE_CASES.md) for documented cases where `agent-guardrails` would have prevented production incidents:
|
|
44
|
+
|
|
45
|
+
| Case | What AI Did | Impact | Guardrails Prevention |
|
|
46
|
+
|------|-------------|--------|----------------------|
|
|
47
|
+
| Parallel Abstraction | Created `RefundNotifier` instead of extending `RefundService` | 40+ hours refactor debt | ✅ Pattern drift detected |
|
|
48
|
+
| Untested Hot Path | Added optimization branch without tests | 45 min downtime, 200+ tickets | ✅ Test relevance check |
|
|
49
|
+
| Cross-Layer Import | Service imported from API layer | 2 AM hotfix required | ✅ Boundary violation |
|
|
50
|
+
| Public Surface Change | Exposed `internal_notes` in API | $50K data exposure | ✅ Interface drift |
|
|
51
|
+
|
|
52
|
+
### What Others Miss
|
|
53
|
+
|
|
54
|
+
| Scenario | CodeRabbit | Sonar | Agent-Guardrails |
|
|
55
|
+
|----------|------------|-------|------------------|
|
|
56
|
+
| Parallel abstraction created | ❌ | ❌ | ✅ |
|
|
57
|
+
| Test doesn't cover new branch | ❌ | ❌ | ✅ |
|
|
58
|
+
| Task scope violation | ❌ | ❌ | ✅ |
|
|
59
|
+
| Missing rollback notes | ❌ | ❌ | ✅ |
|
|
60
|
+
|
|
12
61
|
## Start Here / 先看这里
|
|
13
62
|
|
|
14
|
-
**
|
|
63
|
+
**Try it in 30 seconds:**
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 1. Install
|
|
67
|
+
npm install -g agent-guardrails
|
|
68
|
+
|
|
69
|
+
# 2. Setup in your repo
|
|
70
|
+
cd your-repo
|
|
71
|
+
agent-guardrails setup --agent claude-code
|
|
72
|
+
|
|
73
|
+
# 3. Open Claude Code and ask it to make a change
|
|
74
|
+
# 4. Before merge, check the output:
|
|
75
|
+
# ✓ Did AI stay in scope?
|
|
76
|
+
# ✓ Did tests run?
|
|
77
|
+
# ✓ Any parallel abstractions created?
|
|
78
|
+
# ✓ Any protected files touched?
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**What you get:**
|
|
15
82
|
|
|
16
|
-
|
|
83
|
+
| Before | After |
|
|
84
|
+
|--------|-------|
|
|
85
|
+
| "AI changed 47 files, not sure why" | "AI changed 3 files, all in scope" |
|
|
86
|
+
| "I think tests passed?" | "Tests ran, 12 passed, 0 failed" |
|
|
87
|
+
| "This looks like a new pattern" | "⚠️ Parallel abstraction detected" |
|
|
88
|
+
| "Hope nothing breaks" | "✓ Safe to merge, remaining risk: low" |
|
|
17
89
|
|
|
18
|
-
|
|
19
|
-
2. run `agent-guardrails setup --agent claude-code` in your repo
|
|
20
|
-
3. connect your existing coding agent
|
|
21
|
-
4. describe the task in plain language
|
|
22
|
-
5. get a reviewer summary with scope, validation, and remaining risk
|
|
90
|
+
### Rough-Intent Mode
|
|
23
91
|
|
|
24
|
-
|
|
92
|
+
Don't have a precise task? Start rough:
|
|
25
93
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
94
|
+
```
|
|
95
|
+
I only have a rough idea. Please read the repo rules,
|
|
96
|
+
find the smallest safe change, and finish with a reviewer summary.
|
|
97
|
+
```
|
|
30
98
|
|
|
31
|
-
|
|
99
|
+
Guardrails will suggest **2-3 bounded tasks** based on repo context. Pick one, implement, validate.
|
|
32
100
|
|
|
33
|
-
|
|
101
|
+
See [docs/ROUGH_INTENT.md](./docs/ROUGH_INTENT.md) for details.
|
|
34
102
|
|
|
35
|
-
|
|
36
|
-
2. 在仓库里运行 `agent-guardrails setup --agent claude-code`
|
|
37
|
-
3. 把它接进你现有的 coding agent
|
|
38
|
-
4. 直接用自然语言说任务
|
|
39
|
-
5. 最后拿到 reviewer summary,看这次改了什么、有没有越界、还剩什么风险
|
|
103
|
+
**中文 / Chinese**
|
|
40
104
|
|
|
41
|
-
|
|
105
|
+
```bash
|
|
106
|
+
# 1. 安装
|
|
107
|
+
npm install -g agent-guardrails
|
|
42
108
|
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
|
|
109
|
+
# 2. 在仓库里设置
|
|
110
|
+
cd your-repo
|
|
111
|
+
agent-guardrails setup --agent claude-code
|
|
112
|
+
|
|
113
|
+
# 3. 打开 Claude Code 让 AI 改代码
|
|
114
|
+
# 4. merge 前,看输出:
|
|
115
|
+
# ✓ AI 是否越界?
|
|
116
|
+
# ✓ 测试是否通过?
|
|
117
|
+
# ✓ 是否创建了重复抽象?
|
|
118
|
+
# ✓ 是否触碰了受保护文件?
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
| 之前 | 之后 |
|
|
122
|
+
|------|------|
|
|
123
|
+
| "AI 改了 47 个文件,不知道为什么" | "AI 改了 3 个文件,都在范围内" |
|
|
124
|
+
| "应该测试过了?" | "测试运行完成,12 通过,0 失败" |
|
|
125
|
+
| "这看起来像是个新模式" | "⚠️ 检测到并行抽象" |
|
|
126
|
+
| "希望不会出问题" | "✓ 可以安全 merge,剩余风险:低" |
|
|
47
127
|
|
|
48
128
|
Use website or code-generation tools to get something started.
|
|
49
129
|
Use `agent-guardrails` when the code lives in a real repo and needs to be trusted, reviewed, and maintained.
|
|
@@ -81,21 +161,50 @@ npm run demo
|
|
|
81
161
|
|
|
82
162
|
## Why This Is Different / 为什么它不是另一种生成工具
|
|
83
163
|
|
|
84
|
-
|
|
85
|
-
|
|
164
|
+
### Not a PR Review Bot
|
|
165
|
+
|
|
166
|
+
| PR Review Bot | agent-guardrails |
|
|
167
|
+
|---------------|------------------|
|
|
168
|
+
| Comments **after** code is written | Defines boundaries **before** code is written |
|
|
169
|
+
| Suggests improvements | Enforces constraints |
|
|
170
|
+
| Reactive | Proactive |
|
|
171
|
+
| “This looks wrong” | “This was never allowed” |
|
|
172
|
+
|
|
173
|
+
### Not a Static Analyzer
|
|
86
174
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
175
|
+
| Static Analyzer | agent-guardrails |
|
|
176
|
+
|-----------------|------------------|
|
|
177
|
+
| Generic rules | Repo-specific contracts |
|
|
178
|
+
| No task context | Task-aware scope checking |
|
|
179
|
+
| Style + bugs | AI-behavior patterns |
|
|
180
|
+
| Run in CI | Run **before** CI |
|
|
91
181
|
|
|
92
|
-
|
|
93
|
-
它要解决的是第一轮生成之后,代码还能不能继续信、继续 review、继续维护。
|
|
182
|
+
### Not Another AI Agent
|
|
94
183
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
184
|
+
| AI Agent | agent-guardrails |
|
|
185
|
+
|----------|------------------|
|
|
186
|
+
| Writes code | Validates code |
|
|
187
|
+
| “Let me help you” | “Let me check that” |
|
|
188
|
+
| First wow moment | Long-term trust |
|
|
189
|
+
| Use alone | Use **with** your agent |
|
|
190
|
+
|
|
191
|
+
### The Unique Value
|
|
192
|
+
|
|
193
|
+
`agent-guardrails` sits **between** your AI coding agent and your production:
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
[AI Agent] → [agent-guardrails] → [Your Repo]
|
|
197
|
+
↓
|
|
198
|
+
✓ Scope check
|
|
199
|
+
✓ Test validation
|
|
200
|
+
✓ Drift detection
|
|
201
|
+
✓ Risk summary
|
|
202
|
+
↓
|
|
203
|
+
Safe to merge?
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**No other tool does this.** CodeRabbit reviews after. Sonar checks style. Your AI agent writes code.
|
|
207
|
+
Only `agent-guardrails` is the merge gate that controls AI changes **before** they reach production.
|
|
99
208
|
|
|
100
209
|
## Quick Start / 最短路径
|
|
101
210
|
|
|
@@ -108,17 +217,23 @@ npm install -g agent-guardrails
|
|
|
108
217
|
In your repo, run:
|
|
109
218
|
|
|
110
219
|
```bash
|
|
111
|
-
agent-guardrails setup --agent
|
|
220
|
+
agent-guardrails setup --agent <your-agent>
|
|
112
221
|
```
|
|
113
222
|
|
|
114
223
|
If your agent supports a clearly safe repo-local config path, use:
|
|
115
224
|
|
|
116
225
|
```bash
|
|
117
|
-
agent-guardrails setup --agent
|
|
226
|
+
agent-guardrails setup --agent <your-agent> --write-repo-config
|
|
118
227
|
```
|
|
119
228
|
|
|
120
229
|
Then open your existing agent and start chatting.
|
|
121
230
|
|
|
231
|
+
For the current most opinionated happy path, start with:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
agent-guardrails setup --agent claude-code
|
|
235
|
+
```
|
|
236
|
+
|
|
122
237
|
如果你只知道一个大概方向,也可以直接这样说:
|
|
123
238
|
|
|
124
239
|
- `先帮我看看这个仓库最小能改哪里,尽量别扩大范围,最后告诉我还有什么风险。`
|
|
@@ -132,24 +247,6 @@ Proof in one page:
|
|
|
132
247
|
|
|
133
248
|
## Current Language Support / 当前语言支持
|
|
134
249
|
|
|
135
|
-
**English**
|
|
136
|
-
|
|
137
|
-
- **Deepest support today:** JavaScript / TypeScript
|
|
138
|
-
- **Baseline runtime support today:** Next.js, Python/FastAPI, monorepos
|
|
139
|
-
- **Actively expanding:** deeper Python semantic support and broader framework-aware analysis
|
|
140
|
-
|
|
141
|
-
This means the runtime, setup-first flow, contracts, evidence, and reviewer summary already work outside plain JS/TS repos, but the strongest semantic depth today is still in the TS/JS path.
|
|
142
|
-
|
|
143
|
-
**中文**
|
|
144
|
-
|
|
145
|
-
- **当前最深支持:** JavaScript / TypeScript
|
|
146
|
-
- **当前基础运行时支持:** Next.js、Python/FastAPI、monorepo
|
|
147
|
-
- **正在继续补强:** Python 更深的语义能力,以及更广的框架级分析
|
|
148
|
-
|
|
149
|
-
这意味着现在的 setup、contract、evidence、reviewer summary 已经不只适用于 JS/TS,但真正最强的语义深度仍然在 TS/JS 这条线上。
|
|
150
|
-
|
|
151
|
-
## Current Language Support / 当前语言支持
|
|
152
|
-
|
|
153
250
|
**Today / 当前**
|
|
154
251
|
|
|
155
252
|
- **Deepest support:** JavaScript / TypeScript
|
|
@@ -210,19 +307,13 @@ The product is most valuable when you want three things at once:
|
|
|
210
307
|
The moat is not prompt wording or a chat wrapper.
|
|
211
308
|
The moat is the combination of repo-local contracts, runtime judgment, semantic checks, review structure, workflow integration, and maintenance continuity that compounds with continued use in the same repo.
|
|
212
309
|
|
|
213
|
-
## Setup
|
|
214
|
-
|
|
215
|
-
If you want the intended product entry, install the package and let `setup` prepare the repo plus the agent config you need:
|
|
216
|
-
|
|
217
|
-
```bash
|
|
218
|
-
npm install -g agent-guardrails
|
|
219
|
-
npx agent-guardrails setup --agent claude-code
|
|
220
|
-
```
|
|
310
|
+
## Setup Details / 更多设置
|
|
221
311
|
|
|
222
|
-
If you want the
|
|
312
|
+
If you want the default product entry, let `setup` prepare the repo plus the agent config you need:
|
|
223
313
|
|
|
224
314
|
```bash
|
|
225
315
|
npm install -g agent-guardrails
|
|
316
|
+
npx agent-guardrails setup --agent <your-agent>
|
|
226
317
|
```
|
|
227
318
|
|
|
228
319
|
If your shell does not pick up the global binary right away, skip PATH troubleshooting and run:
|
|
@@ -241,7 +332,7 @@ The runtime is tested in CI on Windows, Linux, and macOS, and the README example
|
|
|
241
332
|
- prints the agent config snippet and tells you exactly where to put it
|
|
242
333
|
- gives you one first chat message and one canonical MCP loop
|
|
243
334
|
|
|
244
|
-
|
|
335
|
+
Examples:
|
|
245
336
|
|
|
246
337
|
```bash
|
|
247
338
|
npx agent-guardrails setup --agent claude-code
|
|
@@ -264,13 +355,6 @@ Today that safe repo-local write path is intended for:
|
|
|
264
355
|
- `openhands` via `.openhands/mcp.json`
|
|
265
356
|
- `openclaw` via `.openclaw/mcp.json`
|
|
266
357
|
|
|
267
|
-
If you want the current most opinionated happy path, use Claude Code first.
|
|
268
|
-
For broader pilot coverage, validate the same setup-first path across:
|
|
269
|
-
|
|
270
|
-
- `claude-code` as the primary path
|
|
271
|
-
- `cursor` and `codex` as secondary paths
|
|
272
|
-
- `openhands` and `openclaw` as supplementary paths
|
|
273
|
-
|
|
274
358
|
Once you connect the generated config to your agent, the happy path should feel like normal chat:
|
|
275
359
|
|
|
276
360
|
- You: `Add refund status transitions to the order service.`
|
|
@@ -278,12 +362,6 @@ Once you connect the generated config to your agent, the happy path should feel
|
|
|
278
362
|
- Agent: makes the change, runs required commands, updates evidence
|
|
279
363
|
- Agent: finishes through `finish_agent_native_loop` and returns a reviewer-friendly summary with scope, risk, and future maintenance guidance
|
|
280
364
|
|
|
281
|
-
If you do not know how to phrase the task yet, you can still start in plain Chinese or plain English:
|
|
282
|
-
|
|
283
|
-
- `先帮我看看这个仓库最小能改哪里,尽量别扩大范围,最后告诉我还有什么风险。`
|
|
284
|
-
- `帮我修这个问题,先读仓库规则,小范围改动,跑完测试后给我 reviewer summary。`
|
|
285
|
-
- `I only have a rough idea. Please read the repo rules, find the smallest safe change, and finish with a reviewer summary.`
|
|
286
|
-
|
|
287
365
|
The first recommended MCP flow is:
|
|
288
366
|
|
|
289
367
|
1. `read_repo_guardrails`
|
|
@@ -327,6 +405,13 @@ If you are not sure about file paths, prefer the MCP flow first. The runtime can
|
|
|
327
405
|
|
|
328
406
|
## External Pilot Paths
|
|
329
407
|
|
|
408
|
+
If you want the current most opinionated happy path, use Claude Code first.
|
|
409
|
+
For broader pilot coverage, validate the same setup-first path across:
|
|
410
|
+
|
|
411
|
+
- `claude-code` as the primary path
|
|
412
|
+
- `cursor` and `codex` as secondary paths
|
|
413
|
+
- `openhands` and `openclaw` as supplementary paths
|
|
414
|
+
|
|
330
415
|
Use the same setup-first loop for all five current agent entries:
|
|
331
416
|
|
|
332
417
|
- `claude-code`
|
|
@@ -439,90 +524,6 @@ npm run demo:boundary-violation
|
|
|
439
524
|
npm run demo:source-test-relevance
|
|
440
525
|
```
|
|
441
526
|
|
|
442
|
-
## Manual CLI Workflow
|
|
443
|
-
|
|
444
|
-
Use this docs-first loop in day-to-day work. Copy it, then replace only the task text and file paths:
|
|
445
|
-
|
|
446
|
-
```bash
|
|
447
|
-
agent-guardrails plan --task "Add audit logging to the release approval endpoint" --required-commands "npm test,npm run lint"
|
|
448
|
-
npm test
|
|
449
|
-
npm run lint
|
|
450
|
-
agent-guardrails check --commands-run "npm test,npm run lint" --review
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
Add `--intended-files`, `--allowed-change-types`, or narrower `--allow-paths` only when you want a tighter task contract than the preset default.
|
|
454
|
-
|
|
455
|
-
The intended low-friction flow is:
|
|
456
|
-
|
|
457
|
-
1. describe the task in plain language with `plan`
|
|
458
|
-
2. make the smallest change that fits the generated contract
|
|
459
|
-
3. run the commands you actually used
|
|
460
|
-
4. finish with the `check` command the runtime recommends
|
|
461
|
-
|
|
462
|
-
If your repo does not have `origin/main`, use the branch that matches your default branch.
|
|
463
|
-
|
|
464
|
-
Keep a short evidence note at `.agent-guardrails/evidence/current-task.md` with:
|
|
465
|
-
|
|
466
|
-
- task name
|
|
467
|
-
- commands run
|
|
468
|
-
- notable results
|
|
469
|
-
- residual risk or `none`
|
|
470
|
-
|
|
471
|
-
Example:
|
|
472
|
-
|
|
473
|
-
```md
|
|
474
|
-
# Task Evidence
|
|
475
|
-
|
|
476
|
-
- Task: Add audit logging to the release approval endpoint
|
|
477
|
-
- Commands run: npm test, npm run lint
|
|
478
|
-
- Notable results: Tests and lint passed after updating the approval endpoint and audit assertions.
|
|
479
|
-
- Residual risk: none
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
## CI and Automation Workflow
|
|
483
|
-
|
|
484
|
-
For CI, hooks, or orchestrated agent runs, prefer machine-readable output:
|
|
485
|
-
|
|
486
|
-
```bash
|
|
487
|
-
agent-guardrails check --base-ref origin/main --json
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
If the workflow wants parity with locally reported commands, set:
|
|
491
|
-
|
|
492
|
-
```text
|
|
493
|
-
AGENT_GUARDRAILS_COMMANDS_RUN=npm test,npm run lint
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
The generated user-repo workflow template lives in [templates/base/workflows/agent-guardrails.yml](./templates/base/workflows/agent-guardrails.yml).
|
|
497
|
-
The maintainer CI for this package lives in [guardrails.yml](./.github/workflows/guardrails.yml).
|
|
498
|
-
|
|
499
|
-
For agent integrations, the recommended entry is the OSS MCP server:
|
|
500
|
-
|
|
501
|
-
```bash
|
|
502
|
-
agent-guardrails mcp
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
The MCP layer exposes the same runtime-backed judgment through these tools:
|
|
506
|
-
|
|
507
|
-
- `read_repo_guardrails`
|
|
508
|
-
- `suggest_task_contract`
|
|
509
|
-
- `start_agent_native_loop`
|
|
510
|
-
- `finish_agent_native_loop`
|
|
511
|
-
- `run_guardrail_check`
|
|
512
|
-
- `summarize_review_risks`
|
|
513
|
-
|
|
514
|
-
The loop tools are the recommended OSS agent-native slice:
|
|
515
|
-
|
|
516
|
-
- `start_agent_native_loop` bootstraps a runtime-backed contract, writes it to the repo, and seeds the evidence note
|
|
517
|
-
- `finish_agent_native_loop` updates evidence, runs `check`, and returns a reviewer-friendly summary from the same judgment path
|
|
518
|
-
|
|
519
|
-
That reviewer-facing result now also carries continuity guidance from the same OSS runtime:
|
|
520
|
-
|
|
521
|
-
- reuse targets to extend first
|
|
522
|
-
- new surface files that broaden the maintenance surface
|
|
523
|
-
- continuity breaks that look like parallel abstractions or structure drift
|
|
524
|
-
- future maintenance risks and continuity-specific next actions
|
|
525
|
-
|
|
526
527
|
## Production Baseline
|
|
527
528
|
|
|
528
529
|
The current product direction is a generic, repo-local production baseline for AI-written code:
|
|
@@ -581,165 +582,9 @@ Deployment orchestration itself remains a later automation layer on top of the s
|
|
|
581
582
|
|
|
582
583
|
The first semantic pack lives publicly in this repo today as an early semantic milestone. It is positioned as the future `Pro Local` direction, not as a separate closed-source runtime.
|
|
583
584
|
|
|
584
|
-
##
|
|
585
|
-
|
|
586
|
-
| Tool | Seeded file | Local workflow support | Automation guidance support |
|
|
587
|
-
| :-- | :-- | :-- | :-- |
|
|
588
|
-
| Codex | `AGENTS.md` | Yes | Yes |
|
|
589
|
-
| Claude Code | `CLAUDE.md` | Yes | Yes |
|
|
590
|
-
| Cursor | `.cursor/rules/agent-guardrails.mdc` | Yes | Yes |
|
|
591
|
-
| OpenHands | `.agents/skills/agent-guardrails.md` | Yes | Yes |
|
|
592
|
-
| OpenClaw | `OPENCLAW.md` | Yes | Yes |
|
|
593
|
-
|
|
594
|
-
## CLI Commands
|
|
595
|
-
|
|
596
|
-
### `init`
|
|
597
|
-
|
|
598
|
-
Seeds a repo with:
|
|
599
|
-
|
|
600
|
-
- `AGENTS.md`
|
|
601
|
-
- `docs/PROJECT_STATE.md`
|
|
602
|
-
- `docs/PR_CHECKLIST.md`
|
|
603
|
-
- `.agent-guardrails/config.json`
|
|
604
|
-
- `.agent-guardrails/tasks/TASK_TEMPLATE.md`
|
|
605
|
-
- `.github/workflows/agent-guardrails.yml`
|
|
606
|
-
|
|
607
|
-
Example:
|
|
608
|
-
|
|
609
|
-
```bash
|
|
610
|
-
agent-guardrails init . --preset nextjs --adapter openclaw
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
If you are not sure what to type, start with `setup --agent <name>`, then use the manual flow only when you want to debug or inspect the runtime directly.
|
|
614
|
-
|
|
615
|
-
### `setup`
|
|
616
|
-
|
|
617
|
-
Auto-initializes the repo when needed, generates the MCP config snippet for a supported agent, and tells you exactly how to start chatting.
|
|
618
|
-
|
|
619
|
-
Example:
|
|
620
|
-
|
|
621
|
-
```bash
|
|
622
|
-
agent-guardrails setup --agent cursor
|
|
623
|
-
agent-guardrails setup --agent claude-code --preset nextjs
|
|
624
|
-
```
|
|
625
|
-
|
|
626
|
-
The happy path is:
|
|
627
|
-
|
|
628
|
-
1. run `setup`
|
|
629
|
-
2. paste the snippet into your agent
|
|
630
|
-
3. ask for the task in chat
|
|
631
|
-
4. let the runtime use `read_repo_guardrails`, `start_agent_native_loop`, and `finish_agent_native_loop`
|
|
632
|
-
|
|
633
|
-
### `plan`
|
|
634
|
-
|
|
635
|
-
Prints a bounded implementation brief and writes a task contract by default.
|
|
636
|
-
|
|
637
|
-
Example:
|
|
638
|
-
|
|
639
|
-
```bash
|
|
640
|
-
agent-guardrails plan --task "Add audit logging to the release approval endpoint" --allow-paths "src/,tests/" --intended-files "src/release/approve.js,tests/release/approve.test.js" --allowed-change-types "implementation-only" --risk-level medium --required-commands "npm test,npm run lint" --evidence ".agent-guardrails/evidence/current-task.md"
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
### `check`
|
|
644
|
-
|
|
645
|
-
Runs baseline guardrail checks against the current repo and git working tree.
|
|
646
|
-
|
|
647
|
-
Example:
|
|
648
|
-
|
|
649
|
-
```bash
|
|
650
|
-
agent-guardrails check --base-ref origin/main --commands-run "npm test,npm run lint" --review
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
For JSON output:
|
|
654
|
-
|
|
655
|
-
```bash
|
|
656
|
-
agent-guardrails check --base-ref origin/main --json
|
|
657
|
-
```
|
|
658
|
-
|
|
659
|
-
Minimal contract example:
|
|
660
|
-
|
|
661
|
-
```json
|
|
662
|
-
{
|
|
663
|
-
"schemaVersion": 3,
|
|
664
|
-
"task": "Add audit logging to the release approval endpoint",
|
|
665
|
-
"preset": "node-service",
|
|
666
|
-
"allowedPaths": ["src/", "tests/"],
|
|
667
|
-
"intendedFiles": ["src/release/approve.js", "tests/release/approve.test.js"],
|
|
668
|
-
"allowedChangeTypes": ["implementation-only"],
|
|
669
|
-
"riskLevel": "medium",
|
|
670
|
-
"requiredCommands": ["npm test", "npm run lint"],
|
|
671
|
-
"evidencePaths": [".agent-guardrails/evidence/current-task.md"]
|
|
672
|
-
}
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
## Presets
|
|
676
|
-
|
|
677
|
-
- `node-service`
|
|
678
|
-
- `nextjs`
|
|
679
|
-
- `python-fastapi`
|
|
680
|
-
- `monorepo`
|
|
681
|
-
|
|
682
|
-
Each preset adjusts file heuristics and recommended read-before-write paths while keeping the same mental model.
|
|
683
|
-
|
|
684
|
-
## Adapters
|
|
685
|
-
|
|
686
|
-
The core workflow is generic, but `agent-guardrails` ships first-pass adapters for:
|
|
687
|
-
|
|
688
|
-
- [Codex](./adapters/codex/README.md)
|
|
689
|
-
- [Claude Code](./adapters/claude-code/README.md)
|
|
690
|
-
- [Cursor](./adapters/cursor/README.md)
|
|
691
|
-
- [OpenHands](./adapters/openhands/README.md)
|
|
692
|
-
- [OpenClaw](./adapters/openclaw/README.md)
|
|
693
|
-
|
|
694
|
-
For Codex, the default `AGENTS.md` workflow is already the main integration surface, so `--adapter codex` is a docs-level adapter rather than an extra seeded file.
|
|
695
|
-
|
|
696
|
-
## FAQ
|
|
697
|
-
|
|
698
|
-
### Do I need all adapters?
|
|
699
|
-
|
|
700
|
-
No. Use only the adapter that matches your coding tool. The core workflow still works without tool-specific seed files.
|
|
701
|
-
|
|
702
|
-
### Do I need evidence files?
|
|
703
|
-
|
|
704
|
-
Only when the task contract declares them. In the default docs-first workflow, the evidence note is intentionally lightweight and meant to record what actually happened.
|
|
705
|
-
|
|
706
|
-
### When should I use `--json`?
|
|
707
|
-
|
|
708
|
-
Use `--json` for CI, hooks, or automation that needs machine-readable results. For normal local work, the human-readable output is the intended default.
|
|
709
|
-
|
|
710
|
-
### Does this work on Windows, Linux, and macOS?
|
|
711
|
-
|
|
712
|
-
Yes. The published CLI is exercised in CI on all three platforms, and the primary install and workflow commands are platform-neutral:
|
|
713
|
-
|
|
714
|
-
- `npm install -g agent-guardrails`
|
|
715
|
-
- `npx agent-guardrails init . --preset node-service`
|
|
716
|
-
- `npx agent-guardrails plan --task "..."`
|
|
717
|
-
- `npx agent-guardrails check --review`
|
|
718
|
-
|
|
719
|
-
Platform-specific commands only appear in docs when a shell-specific workaround is required.
|
|
720
|
-
|
|
721
|
-
### Why not just use another AI to recreate this?
|
|
722
|
-
|
|
723
|
-
You can copy prompts and a chat wrapper.
|
|
724
|
-
The harder part is copying a repo-aware runtime that keeps state across task bootstrap, validation, review, semantic drift checks, continuity guidance, and workflow integration.
|
|
725
|
-
|
|
726
|
-
The value of `agent-guardrails` is not "one clever prompt."
|
|
727
|
-
It is the merge-gate system that existing agent chats call while the runtime keeps getting more aligned to the repo over time.
|
|
728
|
-
|
|
729
|
-
### What if the global `agent-guardrails` command is not found?
|
|
730
|
-
|
|
731
|
-
Use `npx agent-guardrails ...` first. That works across shells and avoids PATH differences between Windows, macOS, and Linux.
|
|
732
|
-
|
|
733
|
-
## Current Limits
|
|
734
|
-
|
|
735
|
-
This project is useful today as a repo-local guardrail layer, but it still has important limits:
|
|
585
|
+
## Deeper Usage
|
|
736
586
|
|
|
737
|
-
|
|
738
|
-
- the semantic detectors are still string- and path-driven, not full AST or type-graph analyzers
|
|
739
|
-
- module boundaries still depend on explicit repo policy instead of automatic architecture inference
|
|
740
|
-
- source-to-test relevance is heuristic and should be treated as reviewer guidance plus contract enforcement, not coverage proof
|
|
741
|
-
- CI users still need to choose their canonical base ref, such as `origin/main`
|
|
742
|
-
- the current pilot is documented in [docs/REAL_REPO_PILOT.md](./docs/REAL_REPO_PILOT.md), and broader external pilots are still pending
|
|
587
|
+
For the full manual CLI flow, supported agents, presets, adapters, FAQ, and current limits, see [docs/WORKFLOWS.md](./docs/WORKFLOWS.md).
|
|
743
588
|
|
|
744
589
|
## Roadmap
|
|
745
590
|
|
|
@@ -752,6 +597,7 @@ See [docs/PRODUCT_STRATEGY.md](./docs/PRODUCT_STRATEGY.md) for the current seman
|
|
|
752
597
|
## More Docs
|
|
753
598
|
|
|
754
599
|
- [Proof](./docs/PROOF.md)
|
|
600
|
+
- [Workflows](./docs/WORKFLOWS.md)
|
|
755
601
|
- [Automation Spec](./docs/AUTOMATION_SPEC.md)
|
|
756
602
|
- [Market Research](./docs/MARKET_RESEARCH.md)
|
|
757
603
|
- [Strategy](./docs/PRODUCT_STRATEGY.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-guardrails",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Production guardrails for AI coding agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"LICENSE"
|
|
13
13
|
],
|
|
14
14
|
"bin": {
|
|
15
|
-
"agent-guardrails": "
|
|
15
|
+
"agent-guardrails": "bin/agent-guardrails.js"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"check": "node ./bin/agent-guardrails.js check",
|