claudify-agent 1.0.7 → 1.0.9
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 +89 -4
- package/README.vi.md +89 -4
- package/bin/cli.js +22 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
## 💡 Overview
|
|
19
19
|
|
|
20
20
|
Inspired by empirical research on autonomous agent failure modes, **`claudify-agent`** acts as the deterministic bridle and operating system for Claude:
|
|
21
|
-
- **Prevents Context Bloat & Token Snowball:** Eliminates token waste and context rot by enforcing sub-20 line rules and on-demand
|
|
21
|
+
- **Prevents Context Bloat & Token Snowball:** Eliminates token waste and context rot by enforcing sub-20 line rules and on-demand modular skill loading (plain path references).
|
|
22
22
|
- **Plan-First Mandate:** Obligates Claude to formulate an explicit execution plan before modifying two or more files.
|
|
23
23
|
- **Zero-Token Local Verification:** Offloads formatting, ESLint corrections, typechecks, and security scans to local scripts rather than burning hundreds of thousands of tokens across LLM feedback loops.
|
|
24
24
|
- **Production Backend & Web3 Ready:** Comprehensive guidelines for high-throughput **Golang**, enterprise **NestJS**, distributed **Concurrency & Locking**, and secure **Solidity Smart Contracts**.
|
|
@@ -34,9 +34,12 @@ npx claudify-agent init
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
This bootstraps:
|
|
37
|
-
- `CLAUDE.md`: The central root steering file auto-loaded by Claude Code CLI.
|
|
37
|
+
- `CLAUDE.md`: The central root steering file auto-loaded by Claude Code CLI. If your project already has one, your content is kept and Claudify only adds/updates a block between `<!-- claudify:start -->` and `<!-- claudify:end -->`.
|
|
38
|
+
- `BACKBONE.md`: Project map (overview, structure, docs index, capabilities, commands, invariants) loaded every session.
|
|
39
|
+
- `spec/config.md`: Rules for writing feature specs.
|
|
40
|
+
- `.claude/commands/`: Slash commands for the spec, backbone and learning workflow.
|
|
38
41
|
- `.claude/rules/`: 13 context-tiered rules governing planning, execution, and security.
|
|
39
|
-
- `.claude/skills/`:
|
|
42
|
+
- `.claude/skills/`: 15 on-demand domain skills (Golang, NestJS, Concurrency, Solidity, Next.js, etc.).
|
|
40
43
|
- `.claude/scripts/`: Local multi-language verification suite (`auto-validate.js`, `security-scan.js`).
|
|
41
44
|
|
|
42
45
|
---
|
|
@@ -57,6 +60,86 @@ Claude Code automatically discovers `CLAUDE.md`. All guardrails, tiered rules, a
|
|
|
57
60
|
|
|
58
61
|
---
|
|
59
62
|
|
|
63
|
+
## 🔁 Daily Workflow
|
|
64
|
+
|
|
65
|
+
Three tools, each with one job:
|
|
66
|
+
|
|
67
|
+
| Tool | Scope | When |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `BACKBONE.md` | Whole project: what it is, where things live, which docs are current | Always loaded, every prompt |
|
|
70
|
+
| `spec/` | One feature at a time | Only when you run `/spec-*` (non-trivial features) |
|
|
71
|
+
| `/learn` | One mistake at a time | After you corrected the AI |
|
|
72
|
+
|
|
73
|
+
### Commands
|
|
74
|
+
|
|
75
|
+
| Command | What it does |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `/backbone-init` | Scan the repo and draft `BACKBONE.md`. Run once per project. Shows a diff, writes after your approval. |
|
|
78
|
+
| `/backbone-sync [area]` | After work done without specs (bug fixes, small features): diff the code since `Last synced`, compare with the backbone and `spec/specs/`, ask about gaps, update the backbone after approval. Never edits archived specs. |
|
|
79
|
+
| `/spec-new <name> <goal>` | Draft ONE file `spec/changes/<name>.md`: Why, Scope/Non-goals, Requirements per capability (ADDED/MODIFIED/REMOVED + GIVEN/WHEN/THEN), Design, Risks, Tasks + DoD. ~800 words; proposes splitting big changes. No code. |
|
|
80
|
+
| `/spec-apply <name> [task]` | Implement the next unchecked task, run its DoD, tick it. One task per call. |
|
|
81
|
+
| `/spec-archive <name>` | Merge the requirements into `spec/specs/<capability>.md` (current truth), move the change to `spec/changes/archive/`, update the backbone. |
|
|
82
|
+
| `/learn [lesson]` | Turn a correction into one rule in the right place (backbone invariant, skill `## Lessons`, or `.claude/rules/lessons.md`). Shows a diff first. |
|
|
83
|
+
|
|
84
|
+
Bugs and trivial tasks: just prompt as usual. No spec needed.
|
|
85
|
+
|
|
86
|
+
### Layout
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
BACKBONE.md ← project map (always loaded)
|
|
90
|
+
spec/
|
|
91
|
+
├── config.md ← how to write specs
|
|
92
|
+
├── changes/
|
|
93
|
+
│ ├── add-refund.md ← in progress
|
|
94
|
+
│ └── archive/2026-11-08-add-export.md ← history
|
|
95
|
+
└── specs/
|
|
96
|
+
└── data-export.md ← current truth, merged on archive
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Example: a feature, end to end
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
> /spec-new add-refund Users can request a refund for a failed order within 7 days
|
|
103
|
+
|
|
104
|
+
AI: Reads BACKBONE.md (already in context), spec/config.md, spec/specs/orders.md.
|
|
105
|
+
Q: Partial refunds in scope? Who approves: auto or admin?
|
|
106
|
+
You: Full refund only, auto-approve.
|
|
107
|
+
AI: Wrote spec/changes/add-refund.md (640 words, 4 tasks). Added it to "Open changes".
|
|
108
|
+
Approve the tasks?
|
|
109
|
+
|
|
110
|
+
> /spec-apply add-refund
|
|
111
|
+
AI: Task 1 done: POST /orders/:id/refund + Zod schema.
|
|
112
|
+
Proof: npm run lint && npm run typecheck && npm test -> 42 passed. Next: task 2.
|
|
113
|
+
|
|
114
|
+
(AI used float for the amount; you correct it)
|
|
115
|
+
> /learn money is always integer cents, never float
|
|
116
|
+
AI: Proposed diff in BACKBONE.md Invariants:
|
|
117
|
+
+ - Money amounts are integer cents; never float.
|
|
118
|
+
Write it? -> yes
|
|
119
|
+
|
|
120
|
+
> /spec-archive add-refund
|
|
121
|
+
AI: Merged 2 ADDED requirements into spec/specs/orders.md,
|
|
122
|
+
moved the change to spec/changes/archive/2026-11-08-add-refund.md,
|
|
123
|
+
updated Capabilities in BACKBONE.md.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Example: after a bug fix without spec
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
> fix: export CSV breaks on commas in names
|
|
130
|
+
AI: Fixed + test. This added docs/csv-format.md, consider /backbone-sync.
|
|
131
|
+
|
|
132
|
+
> /backbone-sync
|
|
133
|
+
AI: 6 commits since a1b2c3d. Gaps:
|
|
134
|
+
- Docs index: docs/csv-format.md missing
|
|
135
|
+
- Commands: `npm run test:e2e` added in CI
|
|
136
|
+
Q: Is docs/export-v1.md still current? It contradicts src/export/csv.ts.
|
|
137
|
+
You: outdated.
|
|
138
|
+
AI: Diff for BACKBONE.md (+3 lines, Last synced: e4f5a6b). Write it?
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
60
143
|
## 🧠 Architecture & ReAct Loop
|
|
61
144
|
|
|
62
145
|
```mermaid
|
|
@@ -80,7 +163,7 @@ graph TD
|
|
|
80
163
|
|
|
81
164
|
---
|
|
82
165
|
|
|
83
|
-
## 🛠️ Included
|
|
166
|
+
## 🛠️ Included 15 Production Skills
|
|
84
167
|
|
|
85
168
|
| Skill | Path | Focus Area |
|
|
86
169
|
| :--- | :--- | :--- |
|
|
@@ -97,6 +180,8 @@ graph TD
|
|
|
97
180
|
| **Tool Selection** | `.claude/skills/tool-selection/SKILL.md` | Decision matrix to minimize excessive LLM tool calls. |
|
|
98
181
|
| **Plan Mastery** | `.claude/skills/plan-mode-mastery/SKILL.md` | Systematic research and execution planning before code generation. |
|
|
99
182
|
| **Vite Guide** | `.claude/skills/vite-guide/SKILL.md` | Modern SPA build optimization and bundling practices. |
|
|
183
|
+
| **Parallel Exploration** | `.claude/skills/parallel-exploration/SKILL.md` | 2-4 parallel read-only Explore subagents for broad discovery. |
|
|
184
|
+
| **Learning Loop** | `.claude/skills/learning-loop/SKILL.md` | Detect anti-patterns from plan metrics and suggest rule updates. |
|
|
100
185
|
|
|
101
186
|
---
|
|
102
187
|
|
package/README.vi.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
## 💡 Tổng Quan
|
|
19
19
|
|
|
20
20
|
Lấy cảm hứng từ các nghiên cứu thực nghiệm về thất bại của AI Agent khi viết code, **`claudify-agent`** đóng vai trò là "dây cương và hệ điều hành" cho Claude:
|
|
21
|
-
- **Chống Tràn Ngữ Cảnh & Hiệu Ứng Tuyết Lăn (Context Snowball):** Triệt tiêu lãng phí token bằng nguyên tắc luật dưới 20 dòng và nạp modular skill theo nhu cầu
|
|
21
|
+
- **Chống Tràn Ngữ Cảnh & Hiệu Ứng Tuyết Lăn (Context Snowball):** Triệt tiêu lãng phí token bằng nguyên tắc luật dưới 20 dòng và nạp modular skill theo nhu cầu qua tham chiếu đường dẫn thường.
|
|
22
22
|
- **Bắt Buộc Lập Kế Hoạch (Plan-First):** Ép Claude phải xuất ra một kế hoạch (Plan) cụ thể trước khi được phép sửa từ 2 file trở lên.
|
|
23
23
|
- **Xác Thực Cục Bộ Tốn 0 Token (Zero-Token Verification):** Đẩy toàn bộ việc sửa format, ESLint, kiểm tra type TypeScript và quét bảo mật cho các script local chạy trên máy tính thay vì đốt hàng trăm ngàn token qua các lượt chat lặp lại của AI.
|
|
24
24
|
- **Sẵn Sàng Cho Production Backend & Web3:** Cung cấp sẵn các cẩm nang chuẩn cho hệ thống **Golang** hiệu năng cao, **NestJS** doanh nghiệp, xử lý **Concurrency & Khóa phân tán (Locking)**, và hợp đồng thông minh **Solidity** an toàn.
|
|
@@ -34,9 +34,12 @@ npx claudify-agent init
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Lệnh này sẽ tự động thiết lập:
|
|
37
|
-
- `CLAUDE.md`: File điều phối trung tâm tự động được nạp bởi Claude Code CLI.
|
|
37
|
+
- `CLAUDE.md`: File điều phối trung tâm tự động được nạp bởi Claude Code CLI. Nếu dự án đã có `CLAUDE.md`, nội dung của bạn được giữ nguyên; Claudify chỉ thêm/cập nhật khối nằm giữa `<!-- claudify:start -->` và `<!-- claudify:end -->`.
|
|
38
|
+
- `BACKBONE.md`: Bản đồ dự án (tổng quan, cấu trúc, docs index, capabilities, lệnh, bất biến), nạp mỗi session.
|
|
39
|
+
- `spec/config.md`: Quy tắc viết spec cho feature.
|
|
40
|
+
- `.claude/commands/`: Slash command cho workflow spec, backbone và tự học từ lỗi.
|
|
38
41
|
- `.claude/rules/`: 13 quy tắc phân tầng kiểm soát quá trình lập plan, thực thi và bảo mật.
|
|
39
|
-
- `.claude/skills/`:
|
|
42
|
+
- `.claude/skills/`: 15 cẩm nang chuyên sâu theo từng công nghệ (Golang, NestJS, Concurrency, Solidity, Next.js...).
|
|
40
43
|
- `.claude/scripts/`: Bộ công cụ tự động kiểm tra code đa ngôn ngữ (`auto-validate.js`, `security-scan.js`).
|
|
41
44
|
|
|
42
45
|
---
|
|
@@ -57,6 +60,86 @@ Claude Code sẽ tự động nhận diện `CLAUDE.md`. Toàn bộ luật bảo
|
|
|
57
60
|
|
|
58
61
|
---
|
|
59
62
|
|
|
63
|
+
## 🔁 Workflow Hằng Ngày
|
|
64
|
+
|
|
65
|
+
Ba công cụ, mỗi cái một việc:
|
|
66
|
+
|
|
67
|
+
| Công cụ | Phạm vi | Khi nào |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `BACKBONE.md` | Toàn dự án: là gì, cái gì nằm đâu, docs nào còn đúng | Luôn được nạp, mọi prompt |
|
|
70
|
+
| `spec/` | Từng feature | Chỉ khi bạn gõ `/spec-*` (feature không tầm thường) |
|
|
71
|
+
| `/learn` | Từng lỗi | Sau khi bạn đã sửa lỗi của AI |
|
|
72
|
+
|
|
73
|
+
### Các lệnh
|
|
74
|
+
|
|
75
|
+
| Lệnh | Làm gì |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `/backbone-init` | Quét repo và viết `BACKBONE.md`. Chạy 1 lần mỗi dự án. Cho xem diff, bạn duyệt mới ghi. |
|
|
78
|
+
| `/backbone-sync [vùng]` | Sau khi làm việc không qua spec (fix bug, feature nhỏ): diff code từ `Last synced`, so với backbone và `spec/specs/`, hỏi chỗ thiếu, cập nhật backbone sau khi bạn duyệt. Không bao giờ sửa spec đã archive. |
|
|
79
|
+
| `/spec-new <tên> <mục tiêu>` | Viết MỘT file `spec/changes/<tên>.md`: Why, Scope/Non-goals, Requirements theo capability (ADDED/MODIFIED/REMOVED + GIVEN/WHEN/THEN), Design, Risks, Tasks + DoD. ~800 từ; tự đề xuất tách change lớn. Không code. |
|
|
80
|
+
| `/spec-apply <tên> [task]` | Làm task chưa tick tiếp theo, chạy DoD, tick. Mỗi lần một task. |
|
|
81
|
+
| `/spec-archive <tên>` | Gộp requirements vào `spec/specs/<capability>.md` (sự thật hiện tại), chuyển change vào `spec/changes/archive/`, cập nhật backbone. |
|
|
82
|
+
| `/learn [bài học]` | Biến lần sửa lỗi thành một rule đúng chỗ (bất biến trong backbone, `## Lessons` của skill, hoặc `.claude/rules/lessons.md`). Cho xem diff trước. |
|
|
83
|
+
|
|
84
|
+
Fix bug và việc nhỏ: cứ prompt như bình thường, không cần spec.
|
|
85
|
+
|
|
86
|
+
### Cấu trúc thư mục
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
BACKBONE.md ← bản đồ dự án (luôn nạp)
|
|
90
|
+
spec/
|
|
91
|
+
├── config.md ← cách viết spec
|
|
92
|
+
├── changes/
|
|
93
|
+
│ ├── add-refund.md ← đang làm
|
|
94
|
+
│ └── archive/2026-11-08-add-export.md ← lịch sử
|
|
95
|
+
└── specs/
|
|
96
|
+
└── data-export.md ← sự thật hiện tại, gộp vào khi archive
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Ví dụ: một feature từ đầu tới cuối
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
> /spec-new add-refund User được yêu cầu hoàn tiền cho order lỗi trong vòng 7 ngày
|
|
103
|
+
|
|
104
|
+
AI: Đọc BACKBONE.md (đã có sẵn), spec/config.md, spec/specs/orders.md.
|
|
105
|
+
Hỏi: Có hoàn tiền một phần không? Ai duyệt: tự động hay admin?
|
|
106
|
+
Bạn: Chỉ hoàn toàn bộ, tự động duyệt.
|
|
107
|
+
AI: Đã viết spec/changes/add-refund.md (640 từ, 4 task). Đã thêm vào "Open changes".
|
|
108
|
+
Duyệt task list chứ?
|
|
109
|
+
|
|
110
|
+
> /spec-apply add-refund
|
|
111
|
+
AI: Task 1 xong: POST /orders/:id/refund + Zod schema.
|
|
112
|
+
Proof: npm run lint && npm run typecheck && npm test -> 42 passed. Tiếp: task 2.
|
|
113
|
+
|
|
114
|
+
(AI dùng float cho số tiền; bạn bảo sửa)
|
|
115
|
+
> /learn tiền luôn là số nguyên (cent), không bao giờ dùng float
|
|
116
|
+
AI: Đề xuất diff trong Invariants của BACKBONE.md:
|
|
117
|
+
+ - Số tiền là số nguyên (cent); không dùng float.
|
|
118
|
+
Ghi chứ? -> có
|
|
119
|
+
|
|
120
|
+
> /spec-archive add-refund
|
|
121
|
+
AI: Đã gộp 2 requirement ADDED vào spec/specs/orders.md,
|
|
122
|
+
chuyển change vào spec/changes/archive/2026-11-08-add-refund.md,
|
|
123
|
+
cập nhật Capabilities trong BACKBONE.md.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Ví dụ: sau khi fix bug không dùng spec
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
> fix: export CSV bị vỡ khi tên có dấu phẩy
|
|
130
|
+
AI: Đã sửa + thêm test. Có thêm docs/csv-format.md, nên chạy /backbone-sync.
|
|
131
|
+
|
|
132
|
+
> /backbone-sync
|
|
133
|
+
AI: 6 commit kể từ a1b2c3d. Chỗ thiếu:
|
|
134
|
+
- Docs index: chưa có docs/csv-format.md
|
|
135
|
+
- Commands: CI có thêm `npm run test:e2e`
|
|
136
|
+
Hỏi: docs/export-v1.md còn đúng không? Nó mâu thuẫn với src/export/csv.ts.
|
|
137
|
+
Bạn: lỗi thời rồi.
|
|
138
|
+
AI: Diff cho BACKBONE.md (+3 dòng, Last synced: e4f5a6b). Ghi chứ?
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
60
143
|
## 🧠 Kiến Trúc Hoạt Động (ReAct Loop)
|
|
61
144
|
|
|
62
145
|
```mermaid
|
|
@@ -81,7 +164,7 @@ graph TD
|
|
|
81
164
|
|
|
82
165
|
---
|
|
83
166
|
|
|
84
|
-
## 🛠️ Danh Mục
|
|
167
|
+
## 🛠️ Danh Mục 15 Kỹ Năng Đính Kèm
|
|
85
168
|
|
|
86
169
|
| Kỹ Năng | Đường Dẫn | Trọng Tâm Giải Quyết |
|
|
87
170
|
| :--- | :--- | :--- |
|
|
@@ -98,6 +181,8 @@ graph TD
|
|
|
98
181
|
| **Tool Selection** | `.claude/skills/tool-selection/SKILL.md` | Chiến lược chọn đúng tool nhằm giảm thiểu số lần gọi API. |
|
|
99
182
|
| **Plan Mastery** | `.claude/skills/plan-mode-mastery/SKILL.md` | Lập kế hoạch bài bản trước khi bắt đầu sinh code. |
|
|
100
183
|
| **Vite Guide** | `.claude/skills/vite-guide/SKILL.md` | Cấu hình bundling SPA tối ưu hiệu năng. |
|
|
184
|
+
| **Parallel Exploration** | `.claude/skills/parallel-exploration/SKILL.md` | Chạy 2-4 subagent Explore song song (chỉ đọc) để khảo sát rộng. |
|
|
185
|
+
| **Learning Loop** | `.claude/skills/learning-loop/SKILL.md` | Phát hiện anti-pattern từ plan metrics và đề xuất cập nhật rule. |
|
|
101
186
|
|
|
102
187
|
---
|
|
103
188
|
|
package/bin/cli.js
CHANGED
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
9
|
import { dirname, join, resolve } from 'path';
|
|
10
|
-
import { cp } from 'fs/promises';
|
|
10
|
+
import { cp, readFile, writeFile } from 'fs/promises';
|
|
11
11
|
import { existsSync } from 'fs';
|
|
12
12
|
|
|
13
|
+
const BLOCK_START = '<!-- claudify:start (managed by `npx claudify init`, edits inside are overwritten) -->';
|
|
14
|
+
const BLOCK_END = '<!-- claudify:end -->';
|
|
15
|
+
|
|
13
16
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
17
|
const __dirname = dirname(__filename);
|
|
15
18
|
const packageRoot = resolve(__dirname, '..');
|
|
@@ -24,9 +27,24 @@ if (command === 'init') {
|
|
|
24
27
|
console.log(`📦 Initializing Claudify in: ${targetDir}`);
|
|
25
28
|
|
|
26
29
|
try {
|
|
27
|
-
// 1.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
// 1. CLAUDE.md: keep the project's own content, manage only the Claudify block
|
|
31
|
+
const claudeMd = join(targetDir, 'CLAUDE.md');
|
|
32
|
+
const block = `${BLOCK_START}\n${(await readFile(join(packageRoot, 'CLAUDE.md'), 'utf-8')).trim()}\n${BLOCK_END}\n`;
|
|
33
|
+
if (!existsSync(claudeMd)) {
|
|
34
|
+
await writeFile(claudeMd, block);
|
|
35
|
+
console.log(' ✅ Created CLAUDE.md (Root agent instruction guidelines)');
|
|
36
|
+
} else {
|
|
37
|
+
const current = await readFile(claudeMd, 'utf-8');
|
|
38
|
+
const start = current.indexOf(BLOCK_START);
|
|
39
|
+
const end = current.indexOf(BLOCK_END);
|
|
40
|
+
if (start !== -1 && end > start) {
|
|
41
|
+
await writeFile(claudeMd, current.slice(0, start) + block + current.slice(end + BLOCK_END.length).replace(/^\n/, ''));
|
|
42
|
+
console.log(' ✅ Updated the Claudify block in CLAUDE.md (your own content untouched)');
|
|
43
|
+
} else {
|
|
44
|
+
await writeFile(claudeMd, `${current.trimEnd()}\n\n${block}`);
|
|
45
|
+
console.log(' ✅ Appended the Claudify block to your existing CLAUDE.md');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
30
48
|
|
|
31
49
|
// 2. Copy .claude folder (never overwrite the project's own settings.json)
|
|
32
50
|
const settingsSrc = join(packageRoot, '.claude', 'settings.json');
|
package/package.json
CHANGED