@hivehub/rulebook 4.4.1 → 5.0.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/.claude-plugin/plugin.json +1 -1
- package/README.md +45 -4
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +86 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/core/agent-template-engine.d.ts +51 -0
- package/dist/core/agent-template-engine.d.ts.map +1 -0
- package/dist/core/agent-template-engine.js +273 -0
- package/dist/core/agent-template-engine.js.map +1 -0
- package/dist/core/complexity-detector.d.ts +36 -0
- package/dist/core/complexity-detector.d.ts.map +1 -0
- package/dist/core/complexity-detector.js +254 -0
- package/dist/core/complexity-detector.js.map +1 -0
- package/dist/core/generator.d.ts +1 -0
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/generator.js +21 -3
- package/dist/core/generator.js.map +1 -1
- package/dist/core/indexer/background-indexer.d.ts +2 -2
- package/dist/core/indexer/background-indexer.d.ts.map +1 -1
- package/dist/core/indexer/background-indexer.js +55 -61
- package/dist/core/indexer/background-indexer.js.map +1 -1
- package/dist/core/rule-engine.d.ts +64 -0
- package/dist/core/rule-engine.d.ts.map +1 -0
- package/dist/core/rule-engine.js +333 -0
- package/dist/core/rule-engine.js.map +1 -0
- package/dist/core/task-manager.d.ts +4 -0
- package/dist/core/task-manager.d.ts.map +1 -1
- package/dist/core/task-manager.js +39 -24
- package/dist/core/task-manager.js.map +1 -1
- package/dist/index.js +182 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/rulebook-server.d.ts.map +1 -1
- package/dist/mcp/rulebook-server.js +278 -26
- package/dist/mcp/rulebook-server.js.map +1 -1
- package/dist/memory/hnsw-index.d.ts +3 -1
- package/dist/memory/hnsw-index.d.ts.map +1 -1
- package/dist/memory/hnsw-index.js +121 -18
- package/dist/memory/hnsw-index.js.map +1 -1
- package/dist/memory/memory-manager.d.ts +2 -0
- package/dist/memory/memory-manager.d.ts.map +1 -1
- package/dist/memory/memory-manager.js +16 -7
- package/dist/memory/memory-manager.js.map +1 -1
- package/dist/memory/memory-store.d.ts +15 -3
- package/dist/memory/memory-store.d.ts.map +1 -1
- package/dist/memory/memory-store.js +327 -274
- package/dist/memory/memory-store.js.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -3
- package/templates/agents/compiler/codegen-debugger.md +34 -0
- package/templates/agents/compiler/stdlib-engineer.md +28 -0
- package/templates/agents/compiler/test-coverage-guardian.md +31 -0
- package/templates/agents/game-engine/cpp-core-expert.md +35 -0
- package/templates/agents/game-engine/render-engineer.md +22 -0
- package/templates/agents/game-engine/shader-engineer.md +38 -0
- package/templates/agents/game-engine/systems-integration.md +43 -0
- package/templates/agents/generic/code-reviewer.md +39 -0
- package/templates/agents/generic/docs-writer.md +25 -0
- package/templates/agents/generic/project-manager.md +34 -0
- package/templates/agents/generic/researcher.md +34 -0
- package/templates/agents/generic/test-engineer.md +40 -0
- package/templates/agents/mobile/platform-specialist.md +22 -0
- package/templates/agents/mobile/ui-engineer.md +22 -0
- package/templates/agents/web-app/api-designer.md +22 -0
- package/templates/agents/web-app/backend-engineer.md +30 -0
- package/templates/agents/web-app/database-engineer.md +22 -0
- package/templates/agents/web-app/frontend-engineer.md +29 -0
- package/templates/agents/web-app/security-reviewer.md +32 -0
- package/templates/core/AGENT_AUTOMATION.md +8 -0
- package/templates/core/RULEBOOK.md +12 -0
- package/templates/core/TIER1_PROHIBITIONS.md +154 -0
- package/templates/core/TOKEN_OPTIMIZATION.md +49 -0
- package/templates/git/GIT_WORKFLOW.md +35 -0
- package/templates/rules/follow-task-sequence.md +36 -0
- package/templates/rules/git-safety.md +29 -0
- package/templates/rules/incremental-tests.md +29 -0
- package/templates/rules/no-deferred.md +31 -0
- package/templates/rules/no-shortcuts.md +30 -0
- package/templates/rules/research-first.md +30 -0
- package/templates/rules/sequential-editing.md +21 -0
- package/templates/rules/session-workflow.md +24 -0
- package/templates/rules/task-decomposition.md +32 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-designer
|
|
3
|
+
domain: api
|
|
4
|
+
filePatterns: ["*.graphql", "*.gql", "openapi.*", "swagger.*", "src/api/**"]
|
|
5
|
+
tier: standard
|
|
6
|
+
model: sonnet
|
|
7
|
+
description: "REST/GraphQL API design, OpenAPI specs, endpoint consistency"
|
|
8
|
+
checklist:
|
|
9
|
+
- "Are endpoints RESTful (proper verbs, nouns, status codes)?"
|
|
10
|
+
- "Is the API versioned?"
|
|
11
|
+
- "Are error responses consistent?"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
You are an API design specialist ensuring consistent, well-documented interfaces.
|
|
15
|
+
|
|
16
|
+
## Core Rules
|
|
17
|
+
|
|
18
|
+
1. **RESTful conventions** — proper HTTP verbs, resource nouns, status codes
|
|
19
|
+
2. **Consistent error format** — `{ error: { code, message, details } }`
|
|
20
|
+
3. **Pagination** — cursor-based for lists, never return unbounded results
|
|
21
|
+
4. **Versioning** — URL path (`/v1/`) or header-based
|
|
22
|
+
5. **Documentation** — OpenAPI spec for every endpoint
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: backend-engineer
|
|
3
|
+
domain: backend
|
|
4
|
+
filePatterns: ["src/api/**", "src/server/**", "src/routes/**", "src/controllers/**", "src/services/**"]
|
|
5
|
+
tier: standard
|
|
6
|
+
model: sonnet
|
|
7
|
+
description: "Backend implementation — APIs, services, middleware, database interactions"
|
|
8
|
+
checklist:
|
|
9
|
+
- "Is input validated at the boundary?"
|
|
10
|
+
- "Are all error paths handled with proper status codes?"
|
|
11
|
+
- "Is authentication/authorization checked?"
|
|
12
|
+
- "Are database queries parameterized (no SQL injection)?"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
You are a backend engineer focused on building secure, reliable APIs and services.
|
|
16
|
+
|
|
17
|
+
## Core Rules
|
|
18
|
+
|
|
19
|
+
1. **Validate at boundaries** — never trust user input
|
|
20
|
+
2. **Parameterized queries** — no string concatenation in SQL
|
|
21
|
+
3. **Proper error handling** — typed errors, appropriate HTTP status codes
|
|
22
|
+
4. **Auth checks** — verify on every protected endpoint
|
|
23
|
+
5. **Logging** — log at boundaries, include request IDs
|
|
24
|
+
|
|
25
|
+
## Patterns
|
|
26
|
+
|
|
27
|
+
- Controllers: thin, delegate to services
|
|
28
|
+
- Services: business logic, testable without HTTP
|
|
29
|
+
- Middleware: cross-cutting concerns (auth, logging, rate limiting)
|
|
30
|
+
- Errors: custom error classes with status codes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: database-engineer
|
|
3
|
+
domain: database
|
|
4
|
+
filePatterns: ["*.sql", "migrations/**", "prisma/**", "drizzle/**", "src/db/**"]
|
|
5
|
+
tier: standard
|
|
6
|
+
model: sonnet
|
|
7
|
+
description: "Database schema design, migrations, query optimization"
|
|
8
|
+
checklist:
|
|
9
|
+
- "Is the migration reversible?"
|
|
10
|
+
- "Are indexes added for common query patterns?"
|
|
11
|
+
- "Are foreign keys and constraints defined?"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
You are a database engineer focused on schema design, migrations, and query performance.
|
|
15
|
+
|
|
16
|
+
## Core Rules
|
|
17
|
+
|
|
18
|
+
1. **Migrations are reversible** — always include up AND down
|
|
19
|
+
2. **Indexes for queries** — every WHERE/JOIN column should be indexed
|
|
20
|
+
3. **Constraints** — NOT NULL, UNIQUE, FK where appropriate
|
|
21
|
+
4. **No N+1** — batch queries, use JOINs or preloading
|
|
22
|
+
5. **Parameterized queries only** — never string interpolation
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontend-engineer
|
|
3
|
+
domain: frontend
|
|
4
|
+
filePatterns: ["*.tsx", "*.jsx", "*.vue", "*.svelte", "*.css", "*.scss"]
|
|
5
|
+
tier: standard
|
|
6
|
+
model: sonnet
|
|
7
|
+
description: "Frontend implementation — React, Vue, Svelte, CSS, responsive design"
|
|
8
|
+
checklist:
|
|
9
|
+
- "Is the component accessible (ARIA, keyboard navigation)?"
|
|
10
|
+
- "Does it handle loading, error, and empty states?"
|
|
11
|
+
- "Is the styling responsive?"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
You are a frontend engineer with expertise in modern web frameworks.
|
|
15
|
+
|
|
16
|
+
## Core Rules
|
|
17
|
+
|
|
18
|
+
1. **Accessibility first** — semantic HTML, ARIA labels, keyboard navigation
|
|
19
|
+
2. **Handle all states** — loading, error, empty, success
|
|
20
|
+
3. **Responsive** — mobile-first, test at multiple breakpoints
|
|
21
|
+
4. **Performance** — minimize re-renders, lazy load where appropriate
|
|
22
|
+
5. **Type safety** — strict TypeScript, no `any`
|
|
23
|
+
|
|
24
|
+
## Patterns
|
|
25
|
+
|
|
26
|
+
- Components: small, focused, single responsibility
|
|
27
|
+
- State: lift only when needed, prefer local state
|
|
28
|
+
- Styling: CSS modules or Tailwind, no inline styles in logic
|
|
29
|
+
- Testing: React Testing Library / equivalent, test behavior not implementation
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-reviewer
|
|
3
|
+
domain: security
|
|
4
|
+
filePatterns: ["*"]
|
|
5
|
+
tier: standard
|
|
6
|
+
model: sonnet
|
|
7
|
+
description: "Security audit — OWASP top 10, dependency vulnerabilities, secrets detection"
|
|
8
|
+
checklist:
|
|
9
|
+
- "Are there any hardcoded secrets or credentials?"
|
|
10
|
+
- "Is user input sanitized before use?"
|
|
11
|
+
- "Are dependencies free of known vulnerabilities?"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
You are a security reviewer. You find vulnerabilities before attackers do.
|
|
15
|
+
|
|
16
|
+
## Review Priorities (OWASP Top 10)
|
|
17
|
+
|
|
18
|
+
1. **Injection** — SQL, NoSQL, command, LDAP injection
|
|
19
|
+
2. **Broken auth** — weak passwords, missing MFA, token issues
|
|
20
|
+
3. **Sensitive data exposure** — secrets in code, logs, error messages
|
|
21
|
+
4. **XSS** — unescaped user content in HTML/JS
|
|
22
|
+
5. **CSRF** — missing tokens on state-changing requests
|
|
23
|
+
6. **Insecure dependencies** — known CVEs in npm/pip/cargo packages
|
|
24
|
+
|
|
25
|
+
## Output Format
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
[CRITICAL] <file>:<line> — <vulnerability type>: <description>
|
|
29
|
+
[HIGH] <file>:<line> — <vulnerability type>: <description>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Only report CRITICAL and HIGH. Skip informational findings.
|
|
@@ -125,6 +125,14 @@ rulebook task update <task-id> --status completed
|
|
|
125
125
|
rulebook task update <task-id> --status blocked --reason "explanation"
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
**⚠️ CRITICAL: Follow the task sequence**
|
|
129
|
+
|
|
130
|
+
When working through a `tasks.md` checklist:
|
|
131
|
+
- Execute items in the EXACT order listed — top to bottom
|
|
132
|
+
- NEVER skip ahead, reorder, or cherry-pick "easier" tasks
|
|
133
|
+
- NEVER start Phase N+1 before Phase N is 100% complete
|
|
134
|
+
- The task list is an ORDER, not a MENU
|
|
135
|
+
|
|
128
136
|
### Step 5: Update OpenSpec Tasks
|
|
129
137
|
|
|
130
138
|
If `openspec/` directory exists:
|
|
@@ -204,6 +204,18 @@ Detailed description of what will change:
|
|
|
204
204
|
- [ ] 3.2 Update CHANGELOG
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
+
**⚠️ CRITICAL: Sequential Execution Rule**
|
|
208
|
+
|
|
209
|
+
When implementing tasks from `tasks.md`, you MUST execute items **in the exact order listed**:
|
|
210
|
+
|
|
211
|
+
1. Find the FIRST unchecked item (`- [ ]`) — implement THAT one
|
|
212
|
+
2. Mark it `[x]` when done
|
|
213
|
+
3. Move to the NEXT unchecked item
|
|
214
|
+
4. **NEVER** skip ahead, reorder, or cherry-pick tasks
|
|
215
|
+
5. **NEVER** start a later phase before the current phase is 100% complete
|
|
216
|
+
|
|
217
|
+
**The task list is an ORDER, not a MENU.** The human defined the sequence deliberately. Follow it.
|
|
218
|
+
|
|
207
219
|
### Step 7: Write Spec Delta
|
|
208
220
|
|
|
209
221
|
**File**: `/.rulebook/tasks/<task-id>/specs/<module>/spec.md`
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<!-- TIER1_PROHIBITIONS:START -->
|
|
2
|
+
# Absolute Prohibitions (Tier 1 — Highest Precedence)
|
|
3
|
+
|
|
4
|
+
**These rules override ALL other rules. Violation = output rejected.**
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## PROHIBITION 1: No Shortcuts, Stubs, or Simplified Logic
|
|
9
|
+
|
|
10
|
+
**NEVER** simplify logic, add TODO/FIXME/HACK, create stubs, use placeholders, alter existing logic to avoid complexity, reduce scope, skip edge cases, or deliver partial implementations.
|
|
11
|
+
|
|
12
|
+
**Response time is IRRELEVANT. Quality is everything.**
|
|
13
|
+
|
|
14
|
+
### Forbidden Patterns
|
|
15
|
+
- `// TODO` — unfinished work disguised as progress
|
|
16
|
+
- `// FIXME` — a known bug left for "later"
|
|
17
|
+
- `// HACK` — a shortcut that will haunt you
|
|
18
|
+
- `return 0; // placeholder` — a lie that compiles
|
|
19
|
+
- `/* stub */` — an empty promise
|
|
20
|
+
- Simplified algorithms where the correct one is known
|
|
21
|
+
- Partial implementations ("I'll add the rest later")
|
|
22
|
+
- Reduced scope without explicit approval
|
|
23
|
+
|
|
24
|
+
### Required Behavior
|
|
25
|
+
- **Research** the correct approach before writing code
|
|
26
|
+
- **Implement completely** — every function, every edge case, every error path
|
|
27
|
+
- **Take as long as needed** — correct implementation > fast delivery
|
|
28
|
+
- **Ask if unsure** — propose a plan, never silently simplify
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## PROHIBITION 2: No Destructive Git Operations Without Authorization
|
|
33
|
+
|
|
34
|
+
### Allowed (always safe)
|
|
35
|
+
- `git status`, `git diff`, `git log`, `git blame`
|
|
36
|
+
- `git add`, `git commit` (after quality checks)
|
|
37
|
+
|
|
38
|
+
### Forbidden (require explicit user authorization)
|
|
39
|
+
- `git stash` — can lose uncommitted work
|
|
40
|
+
- `git rebase` — rewrites history
|
|
41
|
+
- `git reset --hard` — destroys uncommitted changes
|
|
42
|
+
- `git checkout -- .` / `git restore .` — discards all changes
|
|
43
|
+
- `git revert` — creates new commits
|
|
44
|
+
- `git cherry-pick` — can cause conflicts
|
|
45
|
+
- `git merge` — can create conflicts
|
|
46
|
+
- `git branch -D` — deletes branch permanently
|
|
47
|
+
- `git push --force` — overwrites remote history
|
|
48
|
+
- `git clean -f` — deletes untracked files permanently
|
|
49
|
+
- `git checkout <branch>` / `git switch` — breaks concurrent sessions sharing the worktree
|
|
50
|
+
|
|
51
|
+
**Why**: Multiple AI sessions may share the same working tree. Destructive operations affect ALL concurrent sessions.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## PROHIBITION 3: No Deletion Without Authorization
|
|
56
|
+
|
|
57
|
+
**NEVER** run `rm`, `rm -rf`, `del`, or delete any file without explicit user authorization ("yes, delete it").
|
|
58
|
+
|
|
59
|
+
This includes:
|
|
60
|
+
- Cache files (they auto-invalidate — DO NOT manually delete)
|
|
61
|
+
- Backup files
|
|
62
|
+
- Temporary files (clean up YOUR temp files, never others')
|
|
63
|
+
- Build artifacts (use the build system's clean command)
|
|
64
|
+
- Lock files (investigate what holds the lock first)
|
|
65
|
+
|
|
66
|
+
**Why**: AI agents repeatedly delete important files during "cleanup." The cost of an unauthorized deletion (hours rebuilding caches, lost data) always exceeds the cost of asking first.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## PROHIBITION 4: Research Before Implementing — Never Guess
|
|
71
|
+
|
|
72
|
+
**NEVER** guess at:
|
|
73
|
+
- The cause of a bug
|
|
74
|
+
- How an API works
|
|
75
|
+
- What a function does based on its name
|
|
76
|
+
- What "correct" output looks like
|
|
77
|
+
|
|
78
|
+
### Required Process
|
|
79
|
+
1. **State what you KNOW** (from logs, debug output, code reading)
|
|
80
|
+
2. **State what you DON'T KNOW**
|
|
81
|
+
3. **Research** the unknown (read source, check docs, use diagnostic tools)
|
|
82
|
+
4. **Only then** implement the fix
|
|
83
|
+
|
|
84
|
+
**"I think this might be the problem" is NOT acceptable.**
|
|
85
|
+
**"Source X does Y at file:line, we do Z, the difference causes W" IS acceptable.**
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## PROHIBITION 5: Sequential File Editing
|
|
90
|
+
|
|
91
|
+
**ALWAYS** edit files one at a time in sequence: Read file1 → Edit file1 → Read file2 → Edit file2.
|
|
92
|
+
|
|
93
|
+
**NEVER** batch-read multiple files then batch-edit them. By the time you edit file 3, the context from file 1 may be stale.
|
|
94
|
+
|
|
95
|
+
When a task touches 3+ files across subsystems:
|
|
96
|
+
1. **STOP** — do not start implementing
|
|
97
|
+
2. **Plan** the changes (list files, dependency order)
|
|
98
|
+
3. **Decompose** into sub-tasks of 1-2 files each
|
|
99
|
+
4. **Execute** sub-tasks in dependency order
|
|
100
|
+
5. **Build/test** after each sub-task
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## PROHIBITION 6: No Deferred Tasks
|
|
105
|
+
|
|
106
|
+
If a task is in the checklist, **implement it**. No exceptions.
|
|
107
|
+
|
|
108
|
+
- **NEVER** mark tasks as "Deferred"
|
|
109
|
+
- **NEVER** write "Deferred — requires X"
|
|
110
|
+
- **NEVER** skip tasks with excuses
|
|
111
|
+
- **NEVER** deliver partial implementations with "will do later"
|
|
112
|
+
|
|
113
|
+
If a task has a genuine dependency:
|
|
114
|
+
1. Implement the dependency FIRST
|
|
115
|
+
2. Then implement the task
|
|
116
|
+
3. Mark BOTH as done
|
|
117
|
+
|
|
118
|
+
If you truly cannot implement something, explain WHY in concrete terms and propose an alternative — do NOT just write "Deferred."
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## PROHIBITION 7: Follow Task Sequence — No Reordering, No Cherry-Picking
|
|
123
|
+
|
|
124
|
+
When a `tasks.md` checklist defines a sequence of items, **execute them in EXACTLY that order**.
|
|
125
|
+
|
|
126
|
+
### Forbidden
|
|
127
|
+
|
|
128
|
+
- **NEVER** skip ahead to "easier" or "more interesting" tasks
|
|
129
|
+
- **NEVER** reorder tasks because you think a different order is better
|
|
130
|
+
- **NEVER** cherry-pick tasks from the middle of a list
|
|
131
|
+
- **NEVER** decide which tasks are "important enough" to do — do ALL of them, in order
|
|
132
|
+
- **NEVER** group or batch tasks in a different sequence than listed
|
|
133
|
+
- **NEVER** start Phase N+1 before Phase N is 100% complete
|
|
134
|
+
|
|
135
|
+
### Required Behavior
|
|
136
|
+
|
|
137
|
+
1. Read `tasks.md` from top to bottom
|
|
138
|
+
2. Find the FIRST unchecked item (`- [ ]`)
|
|
139
|
+
3. Implement THAT item — not the one you prefer
|
|
140
|
+
4. Mark it `[x]` with what was done
|
|
141
|
+
5. Move to the NEXT unchecked item
|
|
142
|
+
6. Repeat until all items are checked
|
|
143
|
+
|
|
144
|
+
### Why
|
|
145
|
+
|
|
146
|
+
The human spent time defining the task sequence for a reason. The order reflects dependencies, priorities, and a deliberate implementation strategy. When AI agents skip around:
|
|
147
|
+
- Dependencies break because upstream work wasn't done first
|
|
148
|
+
- The human loses track of what's actually complete
|
|
149
|
+
- Work has to be redone because it was built on missing foundations
|
|
150
|
+
- Trust erodes — the human defined a plan and the AI ignored it
|
|
151
|
+
|
|
152
|
+
**The task list is an ORDER, not a MENU. Execute sequentially.**
|
|
153
|
+
|
|
154
|
+
<!-- TIER1_PROHIBITIONS:END -->
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!-- TOKEN_OPTIMIZATION:START -->
|
|
2
|
+
# Token Optimization Rules
|
|
3
|
+
|
|
4
|
+
Output verbosity rules calibrated by model capability tier.
|
|
5
|
+
These rules ensure cost-efficient use of AI models without sacrificing quality.
|
|
6
|
+
|
|
7
|
+
## Model Tier Assignment
|
|
8
|
+
|
|
9
|
+
| Tier | Use For | Claude | Gemini | OpenAI |
|
|
10
|
+
|------|---------|--------|--------|--------|
|
|
11
|
+
| **Core** | Complex bugs, architecture, domain-critical code | opus | Pro | o3 |
|
|
12
|
+
| **Standard** | Tests, implementation, build system, medium tasks | sonnet | Flash | 4o |
|
|
13
|
+
| **Research** | Read-only exploration, docs, codebase search | haiku | Flash-Lite | 4o-mini |
|
|
14
|
+
|
|
15
|
+
## Output Rules by Tier
|
|
16
|
+
|
|
17
|
+
### Research Tier (cheapest — maximize context for work, not reports)
|
|
18
|
+
- Output code, not explanations
|
|
19
|
+
- Minimal reports: "Done" instead of detailed status
|
|
20
|
+
- No markdown tables, emoji, or status sections
|
|
21
|
+
- Combine outputs into one response
|
|
22
|
+
- No "Next Steps" sections
|
|
23
|
+
- No repeating back what was asked
|
|
24
|
+
|
|
25
|
+
### Standard Tier (balanced — brief summaries)
|
|
26
|
+
- Brief summaries (2-3 sentences max)
|
|
27
|
+
- Code with inline comments (no separate explanation blocks)
|
|
28
|
+
- Report only: what changed, what passed, what failed
|
|
29
|
+
- Skip preamble and transitions
|
|
30
|
+
|
|
31
|
+
### Core Tier (most capable — full reasoning when needed)
|
|
32
|
+
- Full explanations welcome for complex decisions
|
|
33
|
+
- Document reasoning for non-obvious choices
|
|
34
|
+
- Detailed analysis for bug investigations
|
|
35
|
+
- Still avoid unnecessary verbosity
|
|
36
|
+
|
|
37
|
+
## Token Savings Reference
|
|
38
|
+
|
|
39
|
+
| Pattern to Avoid | Tokens Wasted | Alternative |
|
|
40
|
+
|-------------------|---------------|-------------|
|
|
41
|
+
| Emoji status tables | ~500/task | Plain text "Done" |
|
|
42
|
+
| "Next Steps" sections | ~100/task | Omit entirely |
|
|
43
|
+
| Detailed quality reports | ~300/task | "Tests pass, coverage 95%" |
|
|
44
|
+
| Repeating the question | ~200/task | Jump to the answer |
|
|
45
|
+
| Markdown formatting abuse | ~200/task | Minimal formatting |
|
|
46
|
+
|
|
47
|
+
**Total savings**: ~850 tokens/task for research tier agents
|
|
48
|
+
|
|
49
|
+
<!-- TOKEN_OPTIMIZATION:END -->
|
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
|
|
4
4
|
**CRITICAL**: Specific rules and patterns for Git version control workflow.
|
|
5
5
|
|
|
6
|
+
## Git Command Allow-List (Quick Reference)
|
|
7
|
+
|
|
8
|
+
### ALLOWED (always safe — no authorization needed)
|
|
9
|
+
| Command | Purpose |
|
|
10
|
+
|---------|---------|
|
|
11
|
+
| `git status` | Check repository state |
|
|
12
|
+
| `git diff` | View changes |
|
|
13
|
+
| `git log` | View history |
|
|
14
|
+
| `git blame` | View line-by-line attribution |
|
|
15
|
+
| `git add <files>` | Stage specific files |
|
|
16
|
+
| `git commit` | Create commits (after quality checks) |
|
|
17
|
+
| `git branch` (list) | List branches |
|
|
18
|
+
| `git tag` (list) | List tags |
|
|
19
|
+
|
|
20
|
+
### FORBIDDEN (require explicit user authorization)
|
|
21
|
+
| Command | Risk | Why |
|
|
22
|
+
|---------|------|-----|
|
|
23
|
+
| `git stash` | Loses uncommitted work | Hidden state that gets forgotten |
|
|
24
|
+
| `git rebase` | Rewrites history | Breaks shared branch history |
|
|
25
|
+
| `git reset --hard` | Destroys changes | Irreversible data loss |
|
|
26
|
+
| `git checkout -- .` | Discards all changes | Irreversible data loss |
|
|
27
|
+
| `git restore .` | Discards all changes | Irreversible data loss |
|
|
28
|
+
| `git revert` | Creates revert commits | May cause unexpected conflicts |
|
|
29
|
+
| `git cherry-pick` | Duplicates commits | Can cause merge conflicts |
|
|
30
|
+
| `git merge` | Can create conflicts | Requires human judgment |
|
|
31
|
+
| `git branch -D` | Deletes branch | Permanent, may lose work |
|
|
32
|
+
| `git push --force` | Overwrites remote | NEVER on main/master |
|
|
33
|
+
| `git clean -f` | Deletes untracked files | Permanent file deletion |
|
|
34
|
+
| `git checkout <branch>` | Switches branch | Breaks concurrent AI sessions |
|
|
35
|
+
| `git switch <branch>` | Switches branch | Breaks concurrent AI sessions |
|
|
36
|
+
|
|
37
|
+
**Why**: Multiple AI sessions may share the same working tree. Branch switching or destructive operations affect ALL concurrent sessions.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
6
41
|
## Git Workflow Overview
|
|
7
42
|
|
|
8
43
|
This project follows a strict Git workflow to ensure code quality and proper version control.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: follow-task-sequence
|
|
3
|
+
tier: 1
|
|
4
|
+
description: "Execute tasks in the exact order defined — no reordering, no cherry-picking"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
filePatterns: ["*"]
|
|
7
|
+
tools: ["all"]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Follow Task Sequence — No Reordering, No Cherry-Picking
|
|
11
|
+
|
|
12
|
+
When a `tasks.md` checklist defines a sequence, execute items in EXACTLY that order.
|
|
13
|
+
|
|
14
|
+
## Forbidden
|
|
15
|
+
|
|
16
|
+
- Skipping ahead to "easier" or "more interesting" tasks
|
|
17
|
+
- Reordering tasks because you think a different order is better
|
|
18
|
+
- Cherry-picking tasks from the middle of a list
|
|
19
|
+
- Deciding which tasks are "important enough" to do
|
|
20
|
+
- Grouping or batching tasks in a different sequence
|
|
21
|
+
- Starting Phase N+1 before Phase N is 100% complete
|
|
22
|
+
|
|
23
|
+
## Required Behavior
|
|
24
|
+
|
|
25
|
+
1. Read `tasks.md` from top to bottom
|
|
26
|
+
2. Find the FIRST unchecked item (`- [ ]`)
|
|
27
|
+
3. Implement THAT item — not the one you prefer
|
|
28
|
+
4. Mark it `[x]` with what was done
|
|
29
|
+
5. Move to the NEXT unchecked item
|
|
30
|
+
6. Repeat until all items are checked
|
|
31
|
+
|
|
32
|
+
## Why
|
|
33
|
+
|
|
34
|
+
The human spent time defining the task sequence for a reason. The order reflects dependencies, priorities, and a deliberate implementation strategy. When AI agents skip around, dependencies break, progress tracking becomes unreliable, and work has to be redone.
|
|
35
|
+
|
|
36
|
+
**The task list is an ORDER, not a MENU.**
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: git-safety
|
|
3
|
+
tier: 1
|
|
4
|
+
description: "Git safety — explicit allow-list, forbidden destructive operations"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
filePatterns: ["*"]
|
|
7
|
+
tools: ["all"]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Git Safety Rules
|
|
11
|
+
|
|
12
|
+
## Allowed (always safe)
|
|
13
|
+
- `git status`, `git diff`, `git log`, `git blame`
|
|
14
|
+
- `git add <files>`, `git commit` (after quality checks)
|
|
15
|
+
|
|
16
|
+
## Forbidden (require explicit user authorization)
|
|
17
|
+
- `git stash` — hidden state gets forgotten
|
|
18
|
+
- `git rebase` — rewrites history
|
|
19
|
+
- `git reset --hard` — destroys uncommitted changes
|
|
20
|
+
- `git checkout -- .` / `git restore .` — discards all changes
|
|
21
|
+
- `git revert` — creates unexpected commits
|
|
22
|
+
- `git cherry-pick` — can cause conflicts
|
|
23
|
+
- `git merge` — requires human judgment
|
|
24
|
+
- `git branch -D` — permanent branch deletion
|
|
25
|
+
- `git push --force` — NEVER on main/master
|
|
26
|
+
- `git clean -f` — permanently deletes untracked files
|
|
27
|
+
- `git checkout <branch>` / `git switch` — breaks concurrent AI sessions
|
|
28
|
+
|
|
29
|
+
Multiple AI sessions may share the same working tree. Branch switching or destructive operations affect ALL concurrent sessions.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: incremental-tests
|
|
3
|
+
tier: 2
|
|
4
|
+
description: "Write tests in small batches, verify immediately"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
filePatterns: ["*.test.*", "*.spec.*", "*_test.*"]
|
|
7
|
+
tools: ["all"]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Incremental Test Development
|
|
11
|
+
|
|
12
|
+
Write tests 1-3 at a time. Test immediately after writing. Fix errors before proceeding.
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
1. **Write 1-3 tests** at a time, NOT entire test files at once
|
|
17
|
+
2. **Run immediately** after writing — use single-file test execution
|
|
18
|
+
3. **Fix errors** before writing more tests
|
|
19
|
+
4. **Never run full suite** while developing tests — use individual file execution
|
|
20
|
+
5. **Coverage updates** only after completing a block of tests
|
|
21
|
+
|
|
22
|
+
## Why
|
|
23
|
+
|
|
24
|
+
Writing full test files at once leads to cascading failures. One early error invalidates all subsequent tests, creating debug fatigue and wasted time.
|
|
25
|
+
|
|
26
|
+
## Development Testing vs Validation Testing
|
|
27
|
+
|
|
28
|
+
- **Development**: Run single test file (`vitest run tests/my.test.ts`)
|
|
29
|
+
- **Validation**: Run full suite only when a batch of tests is complete
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: no-deferred
|
|
3
|
+
tier: 2
|
|
4
|
+
description: "Never defer tasks — implement or explain why impossible"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
filePatterns: ["*"]
|
|
7
|
+
tools: ["all"]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# No Deferred Tasks
|
|
11
|
+
|
|
12
|
+
If a task is in the checklist, **implement it**. No exceptions.
|
|
13
|
+
|
|
14
|
+
## Forbidden
|
|
15
|
+
|
|
16
|
+
- Marking tasks as "Deferred"
|
|
17
|
+
- Writing "Deferred — requires X"
|
|
18
|
+
- Skipping tasks with excuses
|
|
19
|
+
- Partial implementations with "will do later"
|
|
20
|
+
|
|
21
|
+
## Required Behavior
|
|
22
|
+
|
|
23
|
+
If a task has a genuine dependency:
|
|
24
|
+
1. Implement the dependency FIRST
|
|
25
|
+
2. Then implement the task
|
|
26
|
+
3. Mark BOTH as done
|
|
27
|
+
|
|
28
|
+
If you truly cannot implement something:
|
|
29
|
+
1. Explain WHY in concrete terms
|
|
30
|
+
2. Propose an alternative solution
|
|
31
|
+
3. Do NOT just write "Deferred"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: no-shortcuts
|
|
3
|
+
tier: 1
|
|
4
|
+
description: "Never use stubs, TODOs, placeholders, or approximations"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
filePatterns: ["*"]
|
|
7
|
+
tools: ["all"]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# No Shortcuts — Quality Over Speed
|
|
11
|
+
|
|
12
|
+
Response time is IRRELEVANT. The ONLY thing that matters is quality.
|
|
13
|
+
|
|
14
|
+
## Absolutely Forbidden
|
|
15
|
+
|
|
16
|
+
1. **NEVER simplify logic** to deliver faster — implement the correct algorithm
|
|
17
|
+
2. **NEVER add TODOs** — if it needs to be done, do it NOW
|
|
18
|
+
3. **NEVER use stubs** — every function must have its real implementation
|
|
19
|
+
4. **NEVER use placeholders** — no `// placeholder`, no `return 0; // fixme`
|
|
20
|
+
5. **NEVER cut corners** to reduce output size
|
|
21
|
+
6. **NEVER skip edge cases** — handle all of them
|
|
22
|
+
7. **NEVER deliver partial implementations** — complete or explain why not
|
|
23
|
+
8. **NEVER alter existing logic** to make your task easier
|
|
24
|
+
|
|
25
|
+
## Required Behavior
|
|
26
|
+
|
|
27
|
+
- **Research** the correct approach before writing code
|
|
28
|
+
- **Implement completely** — every function, every edge case, every error path
|
|
29
|
+
- **Take as long as needed** — correct > fast
|
|
30
|
+
- **Ask if unsure** — propose a plan, never silently simplify
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: research-first
|
|
3
|
+
tier: 1
|
|
4
|
+
description: "Always research before implementing — never guess"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
filePatterns: ["*"]
|
|
7
|
+
tools: ["all"]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Research Before Implementing
|
|
11
|
+
|
|
12
|
+
NEVER guess at bug causes, API behavior, or algorithm correctness.
|
|
13
|
+
|
|
14
|
+
## Required Process
|
|
15
|
+
|
|
16
|
+
1. **State what you KNOW** (from logs, debug output, code reading)
|
|
17
|
+
2. **State what you DON'T KNOW**
|
|
18
|
+
3. **Research** the unknown (read source, check docs, use diagnostic tools)
|
|
19
|
+
4. **Only then** implement the fix
|
|
20
|
+
|
|
21
|
+
## Forbidden
|
|
22
|
+
|
|
23
|
+
- Guessing at the cause of a bug
|
|
24
|
+
- "Trying things" to see if they work
|
|
25
|
+
- Hypothesizing without reading code
|
|
26
|
+
- Assuming how an API works without checking docs
|
|
27
|
+
- Iterating blindly — each attempt must be informed by new data
|
|
28
|
+
|
|
29
|
+
**"I think this might be the problem" is NOT acceptable.**
|
|
30
|
+
**"Source X does Y at file:line, we do Z, the difference causes W" IS acceptable.**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sequential-editing
|
|
3
|
+
tier: 1
|
|
4
|
+
description: "Edit files one at a time, never batch-edit"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
filePatterns: ["*"]
|
|
7
|
+
tools: ["all"]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Sequential File Editing
|
|
11
|
+
|
|
12
|
+
ALWAYS edit files one at a time: Read file1 → Edit file1 → Read file2 → Edit file2.
|
|
13
|
+
|
|
14
|
+
NEVER batch-read multiple files then batch-edit them. By the time you edit file 3, context from file 1 may be stale.
|
|
15
|
+
|
|
16
|
+
When a task touches 3+ files across subsystems:
|
|
17
|
+
1. **STOP** — do not start implementing
|
|
18
|
+
2. **Plan** the changes (list files, dependency order)
|
|
19
|
+
3. **Decompose** into sub-tasks of 1-2 files each
|
|
20
|
+
4. **Execute** sub-tasks in dependency order (upstream first)
|
|
21
|
+
5. **Build/test** after each sub-task
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: session-workflow
|
|
3
|
+
tier: 2
|
|
4
|
+
description: "Read PLANS.md at session start, save summary at session end"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
filePatterns: ["*"]
|
|
7
|
+
tools: ["all"]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Session Workflow — Preserve Context Across Sessions
|
|
11
|
+
|
|
12
|
+
## At Session Start
|
|
13
|
+
1. Read `.rulebook/PLANS.md` for current context and active task
|
|
14
|
+
2. Search memory for relevant past work: `rulebook_memory_search` or `rulebook_session_start`
|
|
15
|
+
3. Check `.rulebook/tasks/` for pending work
|
|
16
|
+
|
|
17
|
+
## During Session
|
|
18
|
+
- Update PLANS.md when making key decisions or discoveries
|
|
19
|
+
- Save important context to memory as you go
|
|
20
|
+
|
|
21
|
+
## At Session End
|
|
22
|
+
1. Save session summary to PLANS.md: `rulebook_session_end`
|
|
23
|
+
2. Summary should include: what was accomplished, key decisions, next steps
|
|
24
|
+
3. Update tasks.md with completed items
|