@hivehub/rulebook 5.3.3 → 5.4.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.
Files changed (74) hide show
  1. package/README.md +393 -354
  2. package/dist/cli/commands/compress.d.ts +18 -0
  3. package/dist/cli/commands/compress.d.ts.map +1 -0
  4. package/dist/cli/commands/compress.js +100 -0
  5. package/dist/cli/commands/compress.js.map +1 -0
  6. package/dist/cli/commands/index.d.ts +1 -0
  7. package/dist/cli/commands/index.d.ts.map +1 -1
  8. package/dist/cli/commands/index.js +1 -0
  9. package/dist/cli/commands/index.js.map +1 -1
  10. package/dist/cli/commands/init.d.ts.map +1 -1
  11. package/dist/cli/commands/init.js +2 -0
  12. package/dist/cli/commands/init.js.map +1 -1
  13. package/dist/cli/commands/update.d.ts.map +1 -1
  14. package/dist/cli/commands/update.js +2 -0
  15. package/dist/cli/commands/update.js.map +1 -1
  16. package/dist/core/claude-settings-manager.d.ts +7 -0
  17. package/dist/core/claude-settings-manager.d.ts.map +1 -1
  18. package/dist/core/claude-settings-manager.js +31 -14
  19. package/dist/core/claude-settings-manager.js.map +1 -1
  20. package/dist/core/compress/compressor.d.ts +60 -0
  21. package/dist/core/compress/compressor.d.ts.map +1 -0
  22. package/dist/core/compress/compressor.js +232 -0
  23. package/dist/core/compress/compressor.js.map +1 -0
  24. package/dist/core/compress/discover.d.ts +19 -0
  25. package/dist/core/compress/discover.d.ts.map +1 -0
  26. package/dist/core/compress/discover.js +100 -0
  27. package/dist/core/compress/discover.js.map +1 -0
  28. package/dist/core/compress/validator.d.ts +47 -0
  29. package/dist/core/compress/validator.d.ts.map +1 -0
  30. package/dist/core/compress/validator.js +131 -0
  31. package/dist/core/compress/validator.js.map +1 -0
  32. package/dist/core/doctor.d.ts.map +1 -1
  33. package/dist/core/doctor.js +66 -0
  34. package/dist/core/doctor.js.map +1 -1
  35. package/dist/core/generator.d.ts +16 -0
  36. package/dist/core/generator.d.ts.map +1 -1
  37. package/dist/core/generator.js +36 -11
  38. package/dist/core/generator.js.map +1 -1
  39. package/dist/hooks/safe-flag-io.d.ts +77 -0
  40. package/dist/hooks/safe-flag-io.d.ts.map +1 -0
  41. package/dist/hooks/safe-flag-io.js +169 -0
  42. package/dist/hooks/safe-flag-io.js.map +1 -0
  43. package/dist/hooks/terse-activate.d.ts +59 -0
  44. package/dist/hooks/terse-activate.d.ts.map +1 -0
  45. package/dist/hooks/terse-activate.js +149 -0
  46. package/dist/hooks/terse-activate.js.map +1 -0
  47. package/dist/hooks/terse-config.d.ts +51 -0
  48. package/dist/hooks/terse-config.d.ts.map +1 -0
  49. package/dist/hooks/terse-config.js +130 -0
  50. package/dist/hooks/terse-config.js.map +1 -0
  51. package/dist/hooks/terse-mode-tracker.d.ts +78 -0
  52. package/dist/hooks/terse-mode-tracker.d.ts.map +1 -0
  53. package/dist/hooks/terse-mode-tracker.js +213 -0
  54. package/dist/hooks/terse-mode-tracker.js.map +1 -0
  55. package/dist/index.js +11 -1
  56. package/dist/index.js.map +1 -1
  57. package/dist/mcp/rulebook-server.d.ts.map +1 -1
  58. package/dist/mcp/rulebook-server.js +236 -0
  59. package/dist/mcp/rulebook-server.js.map +1 -1
  60. package/dist/types.d.ts +4 -0
  61. package/dist/types.d.ts.map +1 -1
  62. package/package.json +2 -1
  63. package/templates/hooks/terse-activate.ps1 +143 -0
  64. package/templates/hooks/terse-activate.sh +197 -0
  65. package/templates/hooks/terse-mode-tracker.ps1 +153 -0
  66. package/templates/hooks/terse-mode-tracker.sh +187 -0
  67. package/templates/modules/RULEBOOK_MCP.md +52 -0
  68. package/templates/skills/core/rulebook-terse/SKILL.md +116 -0
  69. package/templates/skills/core/rulebook-terse-commit/SKILL.md +96 -0
  70. package/templates/skills/core/rulebook-terse-review/SKILL.md +112 -0
  71. package/dist/cli/commands.d.ts +0 -225
  72. package/dist/cli/commands.d.ts.map +0 -1
  73. package/dist/cli/commands.js +0 -3984
  74. package/dist/cli/commands.js.map +0 -1
package/README.md CHANGED
@@ -1,354 +1,393 @@
1
- # @hivehub/rulebook
2
-
3
- [![npm version](https://img.shields.io/npm/v/@hivehub/rulebook?logo=npm&logoColor=white)](https://www.npmjs.com/package/@hivehub/rulebook)
4
- [![npm downloads](https://img.shields.io/npm/dm/@hivehub/rulebook?logo=npm&logoColor=white)](https://www.npmjs.com/package/@hivehub/rulebook)
5
- [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
6
- [![Node.js](https://img.shields.io/badge/Node.js-20+-339933?logo=nodedotjs&logoColor=white)](https://nodejs.org/)
7
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
8
-
9
- [![Tests](https://img.shields.io/github/actions/workflow/status/hivellm/rulebook/test.yml?label=tests&logo=github)](https://github.com/hivellm/rulebook/actions/workflows/test.yml)
10
- [![Coverage](https://img.shields.io/codecov/c/github/hivellm/rulebook?logo=codecov&logoColor=white)](https://codecov.io/gh/hivellm/rulebook)
11
- [![Build](https://img.shields.io/github/actions/workflow/status/hivellm/rulebook/build.yml?label=build&logo=github)](https://github.com/hivellm/rulebook/actions/workflows/build.yml)
12
- [![Lint](https://img.shields.io/github/actions/workflow/status/hivellm/rulebook/lint.yml?label=lint&logo=github)](https://github.com/hivellm/rulebook/actions/workflows/lint.yml)
13
-
14
- > Tool-agnostic AI development framework. Standardize projects across Claude Code, Cursor, Gemini, Codex, Windsurf, and Copilot with automated templates, quality gates, persistent memory, and framework detection for 28 languages, 17 frameworks, 13 MCP modules, and 20 services.
15
-
16
- ---
17
-
18
- ## Quick Start
19
-
20
- ```bash
21
- # Initialize — auto-detects languages, tools, and complexity
22
- npx @hivehub/rulebook@latest init
23
-
24
- # Update existing project to latest rules
25
- npx @hivehub/rulebook@latest update
26
-
27
- # Check project health
28
- npx @hivehub/rulebook@latest doctor
29
- ```
30
-
31
- That's it. Rulebook detects your stack, generates rules for every AI tool in your project, sets up quality gates, and configures MCP integration — all in one command.
32
-
33
- > Install globally with `npm install -g @hivehub/rulebook` to use `rulebook` directly.
34
-
35
- ---
36
-
37
- ## What Rulebook Does
38
-
39
- AI coding assistants produce inconsistent, error-prone code without clear guidelines. Rulebook gives every AI tool in your project the same set of rules — automatically.
40
-
41
- **One `init`, every tool configured:**
42
-
43
- | What | How |
44
- |------|-----|
45
- | **Rules for every AI tool** | `AGENTS.md` + `CLAUDE.md` + `.cursor/rules/` + Gemini/Copilot/Windsurf configs all generated from a single source of truth |
46
- | **Quality gates** | Pre-commit hooks (lint, type-check, format) + pre-push hooks (build, tests)language-aware, cross-platform |
47
- | **40+ MCP tools** | Task management, persistent memory, skills, decisions, knowledge, learnings, Ralph loop, workspace all via Model Context Protocol |
48
- | **Structural enforcement** | `PreToolUse` hooks block forbidden patterns (deferred tasks, stubs/TODOs, manual task files) before edits reach disk |
49
- | **Session continuity** | Persistent memory across sessions, automatic handoff at context limits, STATE.md live status |
50
- | **Autonomous task solving** | Ralph loop: multi-iteration AI agent with quality gates, learning extraction, pause/resume |
51
- | **28 languages, 17 frameworks** | Auto-detected with confidence scores, language-specific templates and CI/CD workflows |
52
-
53
- ---
54
-
55
- ## Core Features
56
-
57
- ### Modular Rule System
58
-
59
- Rulebook generates a **modular `@import` chain** instead of one massive file:
60
-
61
- ```
62
- CLAUDE.md (thin, ~100 lines)
63
- @imports AGENTS.md team-shared rules
64
- @imports AGENTS.override.md — your project overrides (survives updates)
65
- @imports .rulebook/STATE.md — live task/health status
66
- @imports .rulebook/PLANS.md — session scratchpad
67
- ```
68
-
69
- Path-scoped rules in `.claude/rules/` load only when the AI touches matching files (e.g., TypeScript rules load only for `.ts` files). 5 always-on rules enforce core behaviors: diagnostic-first, fail-twice-escalate, no-deferred, no-shortcuts, sequential-editing.
70
-
71
- ### Persistent Memory
72
-
73
- Context that survives across AI sessions. Decisions, bugs, patterns, and preferences are stored locally and searchable.
74
-
75
- | Component | Technology |
76
- |-----------|-----------|
77
- | Storage | better-sqlite3 (native) with sql.js WASM fallback |
78
- | Search | Hybrid BM25 keyword + HNSW vector (256-dim TF-IDF, no API calls) |
79
- | Ranking | Reciprocal Rank Fusion |
80
- | Privacy | Auto-redact `<private>` tags, local-only storage |
81
-
82
- ```bash
83
- rulebook memory search "authentication approach" # Hybrid search
84
- rulebook memory save "Chose JWT over sessions" # Save context
85
- rulebook memory stats # DB health
86
- ```
87
-
88
- ### Task Management
89
-
90
- Spec-driven development with OpenSpec-compatible format. Phase-prefixed task IDs, mandatory tail items (docs + tests + verify), and automatic archival.
91
-
92
- ```bash
93
- rulebook task create phase1_add-auth # Create task with structure
94
- rulebook task list # See pending work
95
- rulebook task validate phase1_add-auth # Check format
96
- rulebook task archive phase1_add-auth # Archive when done
97
- ```
98
-
99
- Each task gets: `proposal.md` (why), `tasks.md` (checklist), `specs/` (technical requirements with SHALL/MUST keywords and Given/When/Then scenarios).
100
-
101
- ### Ralph Autonomous Loop
102
-
103
- Multi-iteration AI agent that solves tasks from a PRD with fresh context per iteration. 5 quality gates (type-check, lint, tests, coverage, security) must pass before an iteration succeeds.
104
-
105
- ```bash
106
- rulebook ralph init # Generate PRD from tasks
107
- rulebook ralph run --max-iterations 10 # Execute loop
108
- rulebook ralph status # Check progress
109
- rulebook ralph history # Review iterations
110
- ```
111
-
112
- Features: parallel story execution, plan checkpoints, context compression, learning extraction, graceful pause/resume.
113
-
114
- ### Multi-Project Workspace
115
-
116
- One MCP server manages all projects in a monorepo, with fully isolated per-project managers.
117
-
118
- ```bash
119
- rulebook workspace init # Create workspace config
120
- rulebook workspace add ./frontend # Add projects
121
- rulebook mcp init --workspace # Single MCP for all
122
- ```
123
-
124
- Auto-discovers from `pnpm-workspace.yaml`, `turbo.json`, `nx.json`, `lerna.json`, or `*.code-workspace`.
125
-
126
- ### Structural Enforcement Hooks
127
-
128
- 3 `PreToolUse` hooks block forbidden patterns at the tool level — before edits reach disk:
129
-
130
- | Hook | Blocks |
131
- |------|--------|
132
- | `enforce-no-deferred` | `deferred`, `skip`, `later`, `TODO` in tasks.md |
133
- | `enforce-no-shortcuts` | Stubs, placeholders, `HACK`/`FIXME` in source files |
134
- | `enforce-mcp-for-tasks` | Manual `mkdir`/`Write` in `.rulebook/tasks/` |
135
-
136
- Cross-platform (Node.js, no `jq` dependency).
137
-
138
- ---
139
-
140
- ## MCP Server
141
-
142
- 40+ MCP tools exposed via stdio transport. Zero configuration after `rulebook mcp init`.
143
-
144
- ```bash
145
- rulebook mcp init # One-time setup — configures .mcp.json automatically
146
- ```
147
-
148
- | Category | Tools | Examples |
149
- |----------|-------|---------|
150
- | Tasks (7) | CRUD + validate + archive + delete | `rulebook_task_create`, `rulebook_task_list` |
151
- | Skills (6) | List, show, enable, disable, search, validate | `rulebook_skill_enable`, `rulebook_skill_search` |
152
- | Memory (6) | Save, search, get, timeline, stats, cleanup | `rulebook_memory_search`, `rulebook_memory_save` |
153
- | Ralph (4) | Init, run, status, history | `rulebook_ralph_run`, `rulebook_ralph_status` |
154
- | Workspace (4) | List, status, search, tasks | `rulebook_workspace_search`, `rulebook_workspace_tasks` |
155
- | Knowledge (3) | Add, list, show | `rulebook_knowledge_add`, `rulebook_knowledge_list` |
156
- | Decisions (4) | Create, list, show, update | `rulebook_decision_create`, `rulebook_decision_list` |
157
- | Learnings (3) | Capture, list, promote | `rulebook_learn_capture`, `rulebook_learn_list` |
158
- | Analysis (3) | Create, list, show | `rulebook_analysis_create`, `rulebook_analysis_list` |
159
- | Other (3+) | Doctor, rules list, blockers, session, codebase | `rulebook_doctor_run`, `rulebook_rules_list` |
160
-
161
- All tools accept optional `projectId` for workspace routing.
162
-
163
- ---
164
-
165
- ## CLI Reference
166
-
167
- ### Project Setup
168
-
169
- ```bash
170
- rulebook init # Interactive setup (auto-detects everything)
171
- rulebook init --minimal # Essentials only
172
- rulebook init --lean # AGENTS.md as <3KB index
173
- rulebook init --light # No quality enforcement
174
- rulebook update # Update to latest rules
175
- rulebook doctor # 7 health checks
176
- rulebook validate # Check project standards
177
- rulebook health # Health score (0-100)
178
- rulebook fix # Auto-fix common issues
179
- ```
180
-
181
- ### Task Management
182
-
183
- ```bash
184
- rulebook task create <task-id> # Create (phase-prefixed: phase1_add-auth)
185
- rulebook task list # List active tasks
186
- rulebook task show <task-id> # Show details
187
- rulebook task validate <task-id> # Validate format
188
- rulebook task archive <task-id> # Archive completed task
189
- rulebook task delete <task-id> # Delete permanently
190
- ```
191
-
192
- ### Memory & Knowledge
193
-
194
- ```bash
195
- rulebook memory search <query> # Hybrid BM25+vector search
196
- rulebook memory save <text> # Save context
197
- rulebook memory stats # Database health
198
- rulebook memory cleanup # Evict old memories
199
- rulebook knowledge list # View patterns and anti-patterns
200
- rulebook learn list # View captured learnings
201
- rulebook decision list # View architecture decisions
202
- ```
203
-
204
- ### Ralph Autonomous Loop
205
-
206
- ```bash
207
- rulebook ralph init # Generate PRD from tasks
208
- rulebook ralph run # Execute iteration loop
209
- rulebook ralph status # Current progress
210
- rulebook ralph history # Past iterations
211
- rulebook ralph pause # Gracefully pause
212
- rulebook ralph resume # Resume from pause
213
- ```
214
-
215
- ### Workspace
216
-
217
- ```bash
218
- rulebook workspace init # Create workspace config
219
- rulebook workspace add <path> # Add project
220
- rulebook workspace list # List all projects
221
- rulebook workspace status # Status with task counts
222
- ```
223
-
224
- ### Rules & Skills
225
-
226
- ```bash
227
- rulebook rules list # List rules by tier
228
- rulebook rules add <rule> # Install from library
229
- rulebook rules project # Project to all tools
230
- rulebook skill list # List available skills
231
- rulebook skill add <skill-id> # Enable a skill
232
- rulebook skill show <skill-id> # Show skill details
233
- ```
234
-
235
- ### CI/CD & Quality
236
-
237
- ```bash
238
- rulebook workflows # Generate GitHub Actions
239
- rulebook check-deps # Check dependencies
240
- rulebook check-coverage # Check test coverage
241
- rulebook version <major|minor|patch> # Bump version
242
- rulebook changelog # Generate from git commits
243
- ```
244
-
245
- ---
246
-
247
- ## Supported Stack
248
-
249
- **28 Languages**: TypeScript, JavaScript, Python, Rust, Go, Java, Kotlin, C, C++, C#, PHP, Ruby, Swift, Elixir, Dart, Scala, Haskell, Julia, R, Lua, Solidity, Zig, Erlang, Ada, SAS, Lisp, Objective-C, SQL
250
-
251
- **17 Frameworks**: NestJS, Spring Boot, Laravel, Django, Flask, Rails, Symfony, Zend, Angular, React, Vue, Nuxt, Next.js, jQuery, React Native, Flutter, Electron
252
-
253
- **20 Services**: PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, MongoDB, Cassandra, DynamoDB, Redis, Memcached, Elasticsearch, Neo4j, InfluxDB, RabbitMQ, Kafka, S3, Azure Blob, GCS, MinIO
254
-
255
- **13 MCP Modules**: Vectorizer, Synap, Context7, GitHub MCP, Playwright, Memory, Supabase, Notion, Atlassian, Serena, Figma, Grafana, Sequential Thinking
256
-
257
- **23 AI Tools**: Cursor, Windsurf, VS Code, GitHub Copilot, Tabnine, Replit, JetBrains AI, Zed, Aider, Continue, Claude, Claude Code, Gemini, Cline, Amazon Q, Auggie, CodeBuddy, Factory, OpenCode, Kilo, Codex, Codeium, Cursor CLI
258
-
259
- ---
260
-
261
- ## VSCode Extension
262
-
263
- The **Rulebook Dashboard** extension provides full visibility into your AI workflow.
264
-
265
- ```bash
266
- code --install-extension vscode-extension/rulebook-dashboard-*.vsix
267
- ```
268
-
269
- | Tab | Shows |
270
- |-----|-------|
271
- | Agents | Team members with real-time status, memory state, last activity |
272
- | Tasks | Progress bars, expandable details, Archive & Update buttons |
273
- | Memory | Stats (count, DB size, types), full-text search |
274
- | Analysis | Structured analyses with findings and execution plans |
275
- | Doctor | 7 health checks with auto-run |
276
- | Telemetry | MCP tool latency and success rates |
277
-
278
- Status bar: context usage indicator (`ctx 78%` with green/yellow/red), Rulebook button, indexer state.
279
-
280
- ---
281
-
282
- ## Configuration
283
-
284
- All config lives in `.rulebook/rulebook.json`:
285
-
286
- ```json
287
- {
288
- "version": "5.3.0",
289
- "mode": "full",
290
- "features": {
291
- "mcp": true,
292
- "memory": true,
293
- "ralph": true,
294
- "multiAgent": true,
295
- "hooks": true,
296
- "telemetry": false
297
- }
298
- }
299
- ```
300
-
301
- **Key files generated by Rulebook:**
302
-
303
- | File | Purpose |
304
- |------|---------|
305
- | `AGENTS.md` | Team-shared AI rules (regenerated on update) |
306
- | `AGENTS.override.md` | Your project overrides (survives updates) |
307
- | `CLAUDE.md` | Claude Code entry point with @imports |
308
- | `.claude/rules/` | Path-scoped rules (language-specific + always-on) |
309
- | `.claude/settings.json` | Hooks and env vars for Claude Code |
310
- | `.rulebook/specs/` | Detailed spec templates per language/framework |
311
- | `.rulebook/STATE.md` | Machine-written live status |
312
- | `.rulebook/tasks/` | Active task directories |
313
-
314
- ---
315
-
316
- ## Documentation
317
-
318
- Full documentation in [`/docs`](docs/):
319
-
320
- - [Getting Started](docs/guides/GETTING_STARTED.md)
321
- - [Best Practices](docs/guides/BEST_PRACTICES.md)
322
- - [CLI Agents](docs/CLI_AGENTS.md)
323
- - [Roadmap](docs/ROADMAP.md)
324
-
325
- See the full [CHANGELOG](CHANGELOG.md) for version history.
326
-
327
- ---
328
-
329
- ## Contributing
330
-
331
- Contributions welcome! Requires Node.js 20+.
332
-
333
- ```bash
334
- git clone https://github.com/hivellm/rulebook.git
335
- cd rulebook
336
- npm install
337
- npm test
338
- npm run build
339
- ```
340
-
341
- ---
342
-
343
- ## Acknowledgments
344
-
345
- - **[Ralph](https://github.com/snarktank/ralph)** Inspired the autonomous loop integration (multi-iteration AI task solving with fresh context per iteration)
346
- - **[OpenSpec](https://github.com/Fission-AI/openspec)** Influenced the task management format (delta-based specs, Given/When/Then scenarios, requirement-focused organization)
347
-
348
- ---
349
-
350
- ## License
351
-
352
- Apache License 2.0 &copy; HiveLLM Team
353
-
354
- [Issues](https://github.com/hivellm/rulebook/issues) &middot; [Discussions](https://github.com/hivellm/rulebook/discussions) &middot; [npm](https://www.npmjs.com/package/@hivehub/rulebook)
1
+ # @hivehub/rulebook
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@hivehub/rulebook?logo=npm&logoColor=white)](https://www.npmjs.com/package/@hivehub/rulebook)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@hivehub/rulebook?logo=npm&logoColor=white)](https://www.npmjs.com/package/@hivehub/rulebook)
5
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
6
+ [![Node.js](https://img.shields.io/badge/Node.js-20+-339933?logo=nodedotjs&logoColor=white)](https://nodejs.org/)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
8
+
9
+ [![Tests](https://img.shields.io/github/actions/workflow/status/hivellm/rulebook/test.yml?label=tests&logo=github)](https://github.com/hivellm/rulebook/actions/workflows/test.yml)
10
+ [![Build](https://img.shields.io/github/actions/workflow/status/hivellm/rulebook/build.yml?label=build&logo=github)](https://github.com/hivellm/rulebook/actions/workflows/build.yml)
11
+ [![Lint](https://img.shields.io/github/actions/workflow/status/hivellm/rulebook/lint.yml?label=lint&logo=github)](https://github.com/hivellm/rulebook/actions/workflows/lint.yml)
12
+
13
+ > Tool-agnostic AI development framework. Standardize projects across Claude Code, Cursor, Gemini, Codex, Windsurf, and Copilot with automated templates, quality gates, persistent memory, and framework detection for 28 languages, 17 frameworks, 13 MCP modules, and 20 services.
14
+
15
+ ---
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ # Initialize — auto-detects languages, tools, and complexity
21
+ npx @hivehub/rulebook@latest init
22
+
23
+ # Update existing project to latest rules
24
+ npx @hivehub/rulebook@latest update
25
+
26
+ # Check project health
27
+ npx @hivehub/rulebook@latest doctor
28
+ ```
29
+
30
+ That's it. Rulebook detects your stack, generates rules for every AI tool in your project, sets up quality gates, and configures MCP integration — all in one command.
31
+
32
+ > Install globally with `npm install -g @hivehub/rulebook` to use `rulebook` directly.
33
+
34
+ ---
35
+
36
+ ## What Rulebook Does
37
+
38
+ AI coding assistants produce inconsistent, error-prone code without clear guidelines. Rulebook gives every AI tool in your project the same set of rules — automatically.
39
+
40
+ **One `init`, every tool configured:**
41
+
42
+ | What | How |
43
+ |------|-----|
44
+ | **Rules for every AI tool** | `AGENTS.md` + `CLAUDE.md` + `.cursor/rules/` + Gemini/Copilot/Windsurf configs — all generated from a single source of truth |
45
+ | **Quality gates** | Pre-commit hooks (lint, type-check, format) + pre-push hooks (build, tests) language-aware, cross-platform |
46
+ | **44+ MCP tools** | Task management, persistent memory, skills, decisions, knowledge, learnings, Ralph loop, workspace, terse compression + evals all via Model Context Protocol |
47
+ | **Structural enforcement** | `PreToolUse` hooks block forbidden patterns (deferred tasks, stubs/TODOs, manual task files) before edits reach disk |
48
+ | **Session continuity** | Persistent memory across sessions, automatic handoff at context limits, STATE.md live status |
49
+ | **Autonomous task solving** | Ralph loop: multi-iteration AI agent with quality gates, learning extraction, pause/resume |
50
+ | **28 languages, 17 frameworks** | Auto-detected with confidence scores, language-specific templates and CI/CD workflows |
51
+
52
+ ---
53
+
54
+ ## Core Features
55
+
56
+ ### Modular Rule System
57
+
58
+ Rulebook generates a **modular `@import` chain** instead of one massive file:
59
+
60
+ ```
61
+ CLAUDE.md (thin, ~100 lines)
62
+ @imports AGENTS.md team-shared rules
63
+ @imports AGENTS.override.md your project overrides (survives updates)
64
+ @imports .rulebook/STATE.md — live task/health status
65
+ @imports .rulebook/PLANS.md — session scratchpad
66
+ ```
67
+
68
+ Path-scoped rules in `.claude/rules/` load only when the AI touches matching files (e.g., TypeScript rules load only for `.ts` files). 5 always-on rules enforce core behaviors: diagnostic-first, fail-twice-escalate, no-deferred, no-shortcuts, sequential-editing.
69
+
70
+ ### Persistent Memory
71
+
72
+ Context that survives across AI sessions. Decisions, bugs, patterns, and preferences are stored locally and searchable.
73
+
74
+ | Component | Technology |
75
+ |-----------|-----------|
76
+ | Storage | better-sqlite3 (native) with sql.js WASM fallback |
77
+ | Search | Hybrid BM25 keyword + HNSW vector (256-dim TF-IDF, no API calls) |
78
+ | Ranking | Reciprocal Rank Fusion |
79
+ | Privacy | Auto-redact `<private>` tags, local-only storage |
80
+
81
+ ```bash
82
+ rulebook memory search "authentication approach" # Hybrid search
83
+ rulebook memory save "Chose JWT over sessions" # Save context
84
+ rulebook memory stats # DB health
85
+ ```
86
+
87
+ ### Terse Mode — Output & Input Compression (v5.4.0)
88
+
89
+ Structurally-enforced output compression via a SessionStart hook that injects a filtered SKILL.md and a per-turn UserPromptSubmit attention anchor. Four intensity levels aligned with Rulebook's agent tiers — `off` for opus-class reasoning, `brief` for sonnet, `terse` for haiku, `ultra` for CI/automation. Auto-clarity drops compression for security warnings, destructive ops, and quality-gate failures.
90
+
91
+ ```bash
92
+ /rulebook-terse # Activate using tier default
93
+ /rulebook-terse ultra # Maximum compression
94
+ /rulebook-terse off # Disable
95
+ ```
96
+
97
+ Paired with `rulebook compress` — input-side compression for memory files (`CLAUDE.md`, `AGENTS.override.md`, `.rulebook/PLANS.md`):
98
+
99
+ ```bash
100
+ rulebook compress --check CLAUDE.md # Report ratio + validator
101
+ rulebook compress --dry-run CLAUDE.md # Preview
102
+ rulebook compress CLAUDE.md # Rewrite + backup
103
+ rulebook compress --restore CLAUDE.md # Revert from backup
104
+ ```
105
+
106
+ Preserves code blocks, URLs, file paths, dates, and version numbers byte-for-byte.
107
+
108
+ **Measured** against a three-arm eval harness (`baseline` / `terse` / `rulebook-terse`) on 10 real prompts executed through the Claude Code CLI, tokens counted with `tiktoken`:
109
+
110
+ | Arm | Total tokens | vs baseline | vs terse |
111
+ |---|---:|---:|---:|
112
+ | `baseline` (no system prompt) | 2,696 | | −42% |
113
+ | `terse` (control: `Answer concisely.`) | 4,611 | +71% | — |
114
+ | `rulebook-terse` (skill active) | **1,940** | **−28%** | **−58%** |
115
+
116
+ Honest delta is **`rulebook-terse` vs `terse` = 57.9% average lift**, per-prompt range **34% → 77%**. All ten prompts clear the 15% threshold individually. Interestingly, the `terse` control is 71% *larger* than `baseline` — `Answer concisely.` alone steers the model toward structured output (headings, code blocks), which inflates tokens. The skill's explicit rules reverse that effect.
117
+
118
+ Regenerate snapshots against live Claude: `npx tsx evals/cli_run.ts` (shells out to `claude -p`, reuses existing CLI auth). Re-measure offline: `npx tsx evals/measure.ts`.
119
+
120
+ Auto-activates after `rulebook init` or `rulebook update` — SessionStart hook writes to `.rulebook/.terse-mode`, UserPromptSubmit hook emits a ~45-token attention anchor per user message. Opt-out: set `.rulebook/rulebook.json` → `"terse": {"enabled": false}`. Override level: `"terse": {"defaultMode": "brief"}` or export `RULEBOOK_TERSE_MODE=ultra`.
121
+
122
+ See [docs/analysis/caveman/](docs/analysis/caveman/) for the design rationale, [docs/guides/rulebook-terse.md](docs/guides/rulebook-terse.md) for the user guide, and `templates/hooks/terse-*.sh` for the hook source.
123
+
124
+ ### Task Management
125
+
126
+ Spec-driven development with OpenSpec-compatible format. Phase-prefixed task IDs, mandatory tail items (docs + tests + verify), and automatic archival.
127
+
128
+ ```bash
129
+ rulebook task create phase1_add-auth # Create task with structure
130
+ rulebook task list # See pending work
131
+ rulebook task validate phase1_add-auth # Check format
132
+ rulebook task archive phase1_add-auth # Archive when done
133
+ ```
134
+
135
+ Each task gets: `proposal.md` (why), `tasks.md` (checklist), `specs/` (technical requirements with SHALL/MUST keywords and Given/When/Then scenarios).
136
+
137
+ ### Ralph Autonomous Loop
138
+
139
+ Multi-iteration AI agent that solves tasks from a PRD with fresh context per iteration. 5 quality gates (type-check, lint, tests, coverage, security) must pass before an iteration succeeds.
140
+
141
+ ```bash
142
+ rulebook ralph init # Generate PRD from tasks
143
+ rulebook ralph run --max-iterations 10 # Execute loop
144
+ rulebook ralph status # Check progress
145
+ rulebook ralph history # Review iterations
146
+ ```
147
+
148
+ Features: parallel story execution, plan checkpoints, context compression, learning extraction, graceful pause/resume.
149
+
150
+ ### Multi-Project Workspace
151
+
152
+ One MCP server manages all projects in a monorepo, with fully isolated per-project managers.
153
+
154
+ ```bash
155
+ rulebook workspace init # Create workspace config
156
+ rulebook workspace add ./frontend # Add projects
157
+ rulebook mcp init --workspace # Single MCP for all
158
+ ```
159
+
160
+ Auto-discovers from `pnpm-workspace.yaml`, `turbo.json`, `nx.json`, `lerna.json`, or `*.code-workspace`.
161
+
162
+ ### Structural Enforcement Hooks
163
+
164
+ 3 `PreToolUse` hooks block forbidden patterns at the tool level — before edits reach disk:
165
+
166
+ | Hook | Blocks |
167
+ |------|--------|
168
+ | `enforce-no-deferred` | `deferred`, `skip`, `later`, `TODO` in tasks.md |
169
+ | `enforce-no-shortcuts` | Stubs, placeholders, `HACK`/`FIXME` in source files |
170
+ | `enforce-mcp-for-tasks` | Manual `mkdir`/`Write` in `.rulebook/tasks/` |
171
+
172
+ Cross-platform (Node.js, no `jq` dependency).
173
+
174
+ ---
175
+
176
+ ## MCP Server
177
+
178
+ 44+ MCP tools exposed via stdio transport. Zero configuration after `rulebook mcp init`.
179
+
180
+ ```bash
181
+ rulebook mcp init # One-time setup — configures .mcp.json automatically
182
+ ```
183
+
184
+ | Category | Tools | Examples |
185
+ |----------|-------|---------|
186
+ | Tasks (7) | CRUD + validate + archive + delete | `rulebook_task_create`, `rulebook_task_list` |
187
+ | Skills (6) | List, show, enable, disable, search, validate | `rulebook_skill_enable`, `rulebook_skill_search` |
188
+ | Memory (6) | Save, search, get, timeline, stats, cleanup | `rulebook_memory_search`, `rulebook_memory_save` |
189
+ | Ralph (4) | Init, run, status, history | `rulebook_ralph_run`, `rulebook_ralph_status` |
190
+ | Workspace (4) | List, status, search, tasks | `rulebook_workspace_search`, `rulebook_workspace_tasks` |
191
+ | Knowledge (3) | Add, list, show | `rulebook_knowledge_add`, `rulebook_knowledge_list` |
192
+ | Decisions (4) | Create, list, show, update | `rulebook_decision_create`, `rulebook_decision_list` |
193
+ | Learnings (3) | Capture, list, promote | `rulebook_learn_capture`, `rulebook_learn_list` |
194
+ | Analysis (3) | Create, list, show | `rulebook_analysis_create`, `rulebook_analysis_list` |
195
+ | Compress (2) | Compress memory files, list candidates | `rulebook_compress`, `rulebook_compress_list` |
196
+ | Evals (2) | Offline measurement, live API regeneration | `rulebook_evals_measure`, `rulebook_evals_run` |
197
+ | Other (3+) | Doctor, rules list, blockers, session, codebase | `rulebook_doctor_run`, `rulebook_rules_list` |
198
+
199
+ All tools accept optional `projectId` for workspace routing.
200
+
201
+ ---
202
+
203
+ ## CLI Reference
204
+
205
+ ### Project Setup
206
+
207
+ ```bash
208
+ rulebook init # Interactive setup (auto-detects everything)
209
+ rulebook init --minimal # Essentials only
210
+ rulebook init --lean # AGENTS.md as <3KB index
211
+ rulebook init --light # No quality enforcement
212
+ rulebook update # Update to latest rules
213
+ rulebook doctor # 7 health checks
214
+ rulebook validate # Check project standards
215
+ rulebook health # Health score (0-100)
216
+ rulebook fix # Auto-fix common issues
217
+ ```
218
+
219
+ ### Task Management
220
+
221
+ ```bash
222
+ rulebook task create <task-id> # Create (phase-prefixed: phase1_add-auth)
223
+ rulebook task list # List active tasks
224
+ rulebook task show <task-id> # Show details
225
+ rulebook task validate <task-id> # Validate format
226
+ rulebook task archive <task-id> # Archive completed task
227
+ rulebook task delete <task-id> # Delete permanently
228
+ ```
229
+
230
+ ### Memory & Knowledge
231
+
232
+ ```bash
233
+ rulebook memory search <query> # Hybrid BM25+vector search
234
+ rulebook memory save <text> # Save context
235
+ rulebook memory stats # Database health
236
+ rulebook memory cleanup # Evict old memories
237
+ rulebook knowledge list # View patterns and anti-patterns
238
+ rulebook learn list # View captured learnings
239
+ rulebook decision list # View architecture decisions
240
+ ```
241
+
242
+ ### Ralph Autonomous Loop
243
+
244
+ ```bash
245
+ rulebook ralph init # Generate PRD from tasks
246
+ rulebook ralph run # Execute iteration loop
247
+ rulebook ralph status # Current progress
248
+ rulebook ralph history # Past iterations
249
+ rulebook ralph pause # Gracefully pause
250
+ rulebook ralph resume # Resume from pause
251
+ ```
252
+
253
+ ### Workspace
254
+
255
+ ```bash
256
+ rulebook workspace init # Create workspace config
257
+ rulebook workspace add <path> # Add project
258
+ rulebook workspace list # List all projects
259
+ rulebook workspace status # Status with task counts
260
+ ```
261
+
262
+ ### Rules & Skills
263
+
264
+ ```bash
265
+ rulebook rules list # List rules by tier
266
+ rulebook rules add <rule> # Install from library
267
+ rulebook rules project # Project to all tools
268
+ rulebook skill list # List available skills
269
+ rulebook skill add <skill-id> # Enable a skill
270
+ rulebook skill show <skill-id> # Show skill details
271
+ ```
272
+
273
+ ### CI/CD & Quality
274
+
275
+ ```bash
276
+ rulebook workflows # Generate GitHub Actions
277
+ rulebook check-deps # Check dependencies
278
+ rulebook check-coverage # Check test coverage
279
+ rulebook version <major|minor|patch> # Bump version
280
+ rulebook changelog # Generate from git commits
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Supported Stack
286
+
287
+ **28 Languages**: TypeScript, JavaScript, Python, Rust, Go, Java, Kotlin, C, C++, C#, PHP, Ruby, Swift, Elixir, Dart, Scala, Haskell, Julia, R, Lua, Solidity, Zig, Erlang, Ada, SAS, Lisp, Objective-C, SQL
288
+
289
+ **17 Frameworks**: NestJS, Spring Boot, Laravel, Django, Flask, Rails, Symfony, Zend, Angular, React, Vue, Nuxt, Next.js, jQuery, React Native, Flutter, Electron
290
+
291
+ **20 Services**: PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, MongoDB, Cassandra, DynamoDB, Redis, Memcached, Elasticsearch, Neo4j, InfluxDB, RabbitMQ, Kafka, S3, Azure Blob, GCS, MinIO
292
+
293
+ **13 MCP Modules**: Vectorizer, Synap, Context7, GitHub MCP, Playwright, Memory, Supabase, Notion, Atlassian, Serena, Figma, Grafana, Sequential Thinking
294
+
295
+ **23 AI Tools**: Cursor, Windsurf, VS Code, GitHub Copilot, Tabnine, Replit, JetBrains AI, Zed, Aider, Continue, Claude, Claude Code, Gemini, Cline, Amazon Q, Auggie, CodeBuddy, Factory, OpenCode, Kilo, Codex, Codeium, Cursor CLI
296
+
297
+ ---
298
+
299
+ ## VSCode Extension
300
+
301
+ The **Rulebook Dashboard** extension provides full visibility into your AI workflow.
302
+
303
+ ```bash
304
+ code --install-extension vscode-extension/rulebook-dashboard-*.vsix
305
+ ```
306
+
307
+ | Tab | Shows |
308
+ |-----|-------|
309
+ | Agents | Team members with real-time status, memory state, last activity |
310
+ | Tasks | Progress bars, expandable details, Archive & Update buttons |
311
+ | Memory | Stats (count, DB size, types), full-text search |
312
+ | Analysis | Structured analyses with findings and execution plans |
313
+ | Doctor | 7 health checks with auto-run |
314
+ | Telemetry | MCP tool latency and success rates |
315
+
316
+ Status bar: context usage indicator (`ctx 78%` with green/yellow/red), Rulebook button, indexer state.
317
+
318
+ ---
319
+
320
+ ## Configuration
321
+
322
+ All config lives in `.rulebook/rulebook.json`:
323
+
324
+ ```json
325
+ {
326
+ "version": "5.3.0",
327
+ "mode": "full",
328
+ "features": {
329
+ "mcp": true,
330
+ "memory": true,
331
+ "ralph": true,
332
+ "multiAgent": true,
333
+ "hooks": true,
334
+ "telemetry": false
335
+ }
336
+ }
337
+ ```
338
+
339
+ **Key files generated by Rulebook:**
340
+
341
+ | File | Purpose |
342
+ |------|---------|
343
+ | `AGENTS.md` | Team-shared AI rules (regenerated on update) |
344
+ | `AGENTS.override.md` | Your project overrides (survives updates) |
345
+ | `CLAUDE.md` | Claude Code entry point with @imports |
346
+ | `.claude/rules/` | Path-scoped rules (language-specific + always-on) |
347
+ | `.claude/settings.json` | Hooks and env vars for Claude Code |
348
+ | `.rulebook/specs/` | Detailed spec templates per language/framework |
349
+ | `.rulebook/STATE.md` | Machine-written live status |
350
+ | `.rulebook/tasks/` | Active task directories |
351
+
352
+ ---
353
+
354
+ ## Documentation
355
+
356
+ Full documentation in [`/docs`](docs/):
357
+
358
+ - [Getting Started](docs/guides/GETTING_STARTED.md)
359
+ - [Best Practices](docs/guides/BEST_PRACTICES.md)
360
+ - [CLI Agents](docs/CLI_AGENTS.md)
361
+ - [Roadmap](docs/ROADMAP.md)
362
+
363
+ See the full [CHANGELOG](CHANGELOG.md) for version history.
364
+
365
+ ---
366
+
367
+ ## Contributing
368
+
369
+ Contributions welcome! Requires Node.js 20+.
370
+
371
+ ```bash
372
+ git clone https://github.com/hivellm/rulebook.git
373
+ cd rulebook
374
+ npm install
375
+ npm test
376
+ npm run build
377
+ ```
378
+
379
+ ---
380
+
381
+ ## Acknowledgments
382
+
383
+ - **[Ralph](https://github.com/snarktank/ralph)** — Inspired the autonomous loop integration (multi-iteration AI task solving with fresh context per iteration)
384
+ - **[OpenSpec](https://github.com/Fission-AI/openspec)** — Influenced the task management format (delta-based specs, Given/When/Then scenarios, requirement-focused organization)
385
+ - **[Caveman](https://github.com/JuliusBrussee/caveman)** — Grounding for the v5.4.0 terse-mode design (SessionStart + UserPromptSubmit hook pattern, intensity-filtered SKILL.md injection, three-arm eval harness). See [docs/analysis/caveman/](docs/analysis/caveman/) for the full analysis.
386
+
387
+ ---
388
+
389
+ ## License
390
+
391
+ Apache License 2.0 &copy; HiveLLM Team
392
+
393
+ [Issues](https://github.com/hivellm/rulebook/issues) &middot; [Discussions](https://github.com/hivellm/rulebook/discussions) &middot; [npm](https://www.npmjs.com/package/@hivehub/rulebook)