Package Exports
- @hivellm/rulebook
- @hivellm/rulebook/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hivellm/rulebook) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@hivellm/rulebook
CLI tool to standardize AI-generated projects with templates, rules enforcement, workflow generation, CI/CD monitoring, and complete publication support for 11 programming languages.
Features
- ๐ Auto-Detection: Automatically detects project language (11 languages) and MCP modules
- ๐ Template System: 65 pre-built templates for languages, modules, IDEs, workflows, and Git
- ๐ Smart Merging: Intelligently merges with existing AGENTS.md files without losing content
- ๐ฏ Customizable: Configure coverage thresholds, documentation strictness, Git workflow, and more
- ๐ซ Rules Ignore: Selectively disable rules using
.rulesignorefile - ๐ค AI-Optimized: Works with 23 AI coding assistants and 8 IDEs
- ๐ฆ Publication Ready: Complete CI/CD pipelines for all package registries
- ๐ CI/CD Monitoring: GitHub MCP integration for automated workflow validation
- ๐จ Git Workflow: Quality gates, conventional commits, and version management
๐ Advanced Features (v0.10.0)
- ๐ OpenSpec Integration: Task management system with dependency tracking
- ๐๏ธ Real-time Watcher [BETA]: Live monitoring of task progress with beautiful ANSI UI
- ๐ค Autonomous Agent [BETA]: Automated workflow management for AI CLI tools
- โ๏ธ Configuration Management:
.rulebookconfig file with feature toggles - ๐ Persistent Logging: Comprehensive logging system with rotation
- ๐ณ Dependency Graphs: Visual task dependency trees and validation
- ๐ CLI Bridge: Seamless integration with cursor-agent
- ๐ Telemetry: Performance metrics and execution analytics
- ๐ Agent Automation [NEW]: CRITICAL mandatory workflow that forces AI agents to execute quality checks, update OpenSpec, and maintain documentation after EVERY implementation
Installation
# NPX (recommended - no installation needed)
npx @hivellm/rulebook@latest init
# Or install globally
npm install -g @hivellm/rulebook@latest
rulebook init
# Or install locally
npm install --save-dev @hivellm/rulebook@latest
npx rulebook initQuick Start
Navigate to your project directory and run:
npx @hivellm/rulebook initThe CLI will:
- Detect your project's language(s) and structure
- Detect available MCP modules (Vectorizer, Synap, etc.)
- Ask configuration questions
- Generate or merge AGENTS.md with best practices
- Optionally generate GitHub Actions workflows
Usage
Interactive Mode
npx @hivellm/rulebook@latest initAnswer the prompts to customize your configuration:
- Language selection
- Project type (application, library, CLI, monorepo)
- MCP modules to include
- IDE preferences
- Coverage threshold (default: 95%)
- Documentation strictness
Auto Mode
Use detected defaults without prompts:
npx @hivellm/rulebook@latest init --yesValidation
Validate your project structure against rulebook standards:
npx @hivellm/rulebook@latest validateChecks:
- AGENTS.md presence and quality
- Documentation structure (/docs directory)
- Tests directory existence
- .rulesignore patterns
- Project quality score (0-100)
Dependency Checking
Check for outdated and vulnerable dependencies:
npx @hivellm/rulebook@latest check-depsSupports:
- npm (package.json)
- Cargo (Cargo.toml)
- Python (requirements.txt, pyproject.toml)
- Go (go.mod)
- Maven/Gradle (pom.xml, build.gradle)
Coverage Verification
Verify test coverage meets threshold:
npx @hivellm/rulebook@latest check-coverage
# Custom threshold
npx @hivellm/rulebook@latest check-coverage --threshold 90Supports: All languages (Rust, TypeScript, Python, Go, Java, etc.)
Version Management
Bump project version automatically:
# Bump patch version (1.0.0 โ 1.0.1)
npx @hivellm/rulebook@latest version patch
# Bump minor version (1.0.0 โ 1.1.0)
npx @hivellm/rulebook@latest version minor
# Bump major version (1.0.0 โ 2.0.0)
npx @hivellm/rulebook@latest version majorUpdates: package.json, Cargo.toml, pyproject.toml, mix.exs, build.gradle.kts, .csproj
Changelog Generation
Generate CHANGELOG.md from git commits:
# Auto-detect version
npx @hivellm/rulebook@latest changelog
# Specify version
npx @hivellm/rulebook@latest changelog --version 1.2.0Features:
- Parses conventional commits
- Categorizes changes (Added, Changed, Fixed, Breaking)
- Updates CHANGELOG.md with proper formatting
- Detects breaking changes automatically
Project Health Check
Analyze project health across multiple dimensions:
npx @hivellm/rulebook@latest healthAnalyzes:
- ๐ Documentation (README, CHANGELOG, LICENSE, docs/)
- ๐งช Testing (tests/, coverage, test frameworks)
- ๐จ Code Quality (linters, formatters, type checking)
- ๐ Security (SECURITY.md, .gitignore, secrets detection)
- ๐ CI/CD (GitHub Actions workflows)
- ๐ฆ Dependencies (lock files, vulnerabilities)
Output: Overall score (0-100) with grade (A+ to F) and category breakdowns
Custom Templates
Add your own templates to extend rulebook:
# Initialize custom templates directory
mkdir -p .rulebook/templates/{language,module,workflow,ide,cli}
# Add your custom template
echo "<!-- CUSTOM:START -->" > .rulebook/templates/language/CUSTOM.md
# ... add your template content ...
echo "<!-- CUSTOM:END -->" >> .rulebook/templates/language/CUSTOM.md
# Custom templates are automatically detected
npx @hivellm/rulebook@latest initSupports: Custom templates for all categories
Auto-Fix Common Issues
Automatically fix common project issues:
npx @hivellm/rulebook@latest fixFixes:
- Creates missing .gitignore with comprehensive patterns
- Creates missing LICENSE (MIT template)
- Creates missing README.md with template
- Creates /docs directory for documentation
- Runs code formatting (npm run format)
- Fixes lint errors automatically (npm run lint --fix)
Integrates with health command: Improves project health score automatically
๐ Advanced Commands (v0.10.0)
Real-time Watcher [BETA]
Monitor task progress with simplified progress-focused interface:
# Start modern watcher (simplified UI) [BETA]
rulebook watcher
# Features:
# - Clean progress-focused layout (25% tasks, 10% progress, 65% logs)
# - Real-time progress bar with color coding
# - Active tasks display with loading indicators
# - Live activity logs with timestamps
# - Automatic task removal on completion
# - Performance optimized (throttled rendering)
# - Memory usage monitoring
# - Ctrl+C/F10 to exitNew Simplified UI Layout:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ค RULEBOOK WATCHER [F10] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ PROGRESS โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 65% - 13/20 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ ACTIVE TASKS โ
โ โถ abc12345 - Implement cursor-agent parser โ
โ โ def67890 - Write integration tests โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ ACTIVITY LOGS โ
โ [14:32:15] โ Task completed: Add parser tests โ
โ [14:32:18] i Starting task: Implement parser โ
โ [14:32:20] โบ Reading src/parser.ts โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโAutonomous Agent [BETA]
Automated workflow management for AI CLI tools:
# Start agent with cursor-agent (recommended) [BETA]
rulebook agent --tool cursor-agent --iterations 5
# Dry-run mode (simulate without changes)
rulebook agent --dry-run
# With watcher integration
rulebook agent --watchโจ cursor-agent Integration (Fully Implemented)
The cursor-agent CLI provides the most advanced integration with:
- Real-time Progress: Live streaming of AI responses and tool calls
- JSON Stream Parsing: Processes events as they arrive (system, user, assistant, tool_call, result)
- Automatic Completion: Detects when tasks finish and continues workflow
- Tool Call Tracking: Shows all file reads, writes, and bash commands in real-time
- Auto-approval Flags: Uses
--forceand--approve-mcpsfor non-interactive execution - Long Timeout: 30-minute default for complex tasks
- Detailed Logging: Full visibility into what the AI is doing
Installation:
# Install cursor-agent globally
npm install -g cursor-agent
# Authenticate (required)
cursor-agent login
# Test installation
cursor-agent --versionExample Output:
๐ Connecting to cursor-agent...
โ
Received first response from cursor-agent!
๐ค Using model: Auto
๐ Working directory: /project
๐ Generating: 189 chars
๐ Tool #1: Reading src/index.ts
โ
Read 150 lines
๐ง Tool #2: Creating tests/index.test.ts
โ
Created 45 lines (1024 bytes)
๐ฏ Completed in 5432ms (6s total)
๐ Final stats: 2 tools, 189 chars generatedNote: claude-code and gemini-cli integrations are implemented but temporarily disabled in v0.10.0. They will be re-enabled in a future release.
Configuration Management
Manage .rulebook configuration:
# Show current configuration
rulebook config --show
# Set configuration values
rulebook config --set coverageThreshold=90
rulebook config --set maxParallelTasks=3
# Enable/disable features
rulebook config --feature watcher --enable
rulebook config --feature notifications --disableOpenSpec Task Management
Manage tasks and dependencies:
# List all tasks
rulebook tasks
# Show dependency tree
rulebook tasks --tree
# Show current task
rulebook tasks --current
# Update task status
rulebook tasks --status task-123Documentation Structure Generation
Generate complete documentation structure and standard open source files:
npx @hivellm/rulebook@latest generate-docs
# Auto mode
npx @hivellm/rulebook@latest generate-docs --yesGenerates:
/docsdirectory structure (specs, guides, diagrams, benchmarks, etc.)CONTRIBUTING.md- Contribution guidelinesCODE_OF_CONDUCT.md- Code of conductSECURITY.md- Security policydocs/ROADMAP.md- Project roadmapdocs/ARCHITECTURE.md- System architecturedocs/DAG.md- Component dependencies
Supported Languages (11)
- โ Rust: Edition 2024, Clippy, Cargo fmt, nextest, llvm-cov โ crates.io
- โ TypeScript: ESLint, Prettier, Vitest, strict mode โ npm
- โ Python: Ruff, Black, mypy, pytest โ PyPI
- โ Go: gofmt, golangci-lint, go vet, table-driven tests โ pkg.go.dev
- โ Java: Maven/Gradle, JUnit 5, Checkstyle, PMD, SpotBugs โ Maven Central
- โ Elixir: Mix, Credo, Dialyzer, ExUnit โ Hex.pm
- โ C#: .NET 8+, nullable types, Roslyn analyzers โ NuGet
- โ PHP: PHP 8.2+, PHPStan, PHP-CS-Fixer, PHPUnit โ Packagist
- โ Swift: Swift 5.10+, SwiftLint, strict concurrency โ SPM
- โ Kotlin: Kotlin 2.0+, K2 compiler, Detekt, ktlint โ Maven Central
- โ C/C++: C++20/23, CMake, clang-format, clang-tidy, Google Test โ Conan/vcpkg
Supported MCP Modules (6)
- โ Vectorizer: Semantic search and codebase exploration
- โ Synap: Key-value store for task and data persistence
- โ OpenSpec: Change proposal and specification workflow
- โ Context7: Library documentation for dependency management
- โ GitHub MCP: Automated workflow validation and CI/CD monitoring
- โ Playwright: Automated browser testing and web automation
Supported IDEs & AI Tools (23 total)
IDEs (8)
- โ Cursor: Cursor-specific rules format (Agent mode, Composer)
- โ Windsurf: Windsurf configuration (Cascade AI, Flow State)
- โ VS Code: VS Code AI extensions (Copilot, Cody, Continue)
- โ GitHub Copilot: Copilot instructions and best practices
- โ Tabnine: Multi-IDE AI completion (VS Code, JetBrains, Vim, Sublime)
- โ Replit: Cloud IDE with Ghostwriter AI
- โ JetBrains AI: AI Assistant (IntelliJ, PyCharm, WebStorm, GoLand, RustRover, Rider, CLion, PhpStorm)
- โ Zed: High-performance collaborative editor (Rust-powered)
CLI & API Agents (15)
- โ Aider: AI pair programming in terminal
- โ Continue: Open-source Copilot alternative
- โ Claude: Anthropic Claude API/CLI (200K context)
- โ Claude Code: Advanced Anthropic coding assistant
- โ Gemini: Google Gemini API/CLI (2M context)
- โ Cursor CLI: Cursor automation and scripting
- โ Codeium: Free AI coding assistant
- โ Cline: VS Code extension and CLI with quality gates
- โ Amazon Q Developer: AWS-focused with security scanning
- โ Auggie (Augment CLI): TDD mode and intelligent refactoring
- โ CodeBuddy Code: Intelligent pair programming
- โ Factory Droid: Code generation and automation
- โ OpenCode: Open-source AI assistant
- โ Kilo Code: Lightweight coding companion
- โ Codex: OpenAI code generation integration
Documentation Structure
Rulebook enforces a clean documentation structure:
project/
โโโ README.md # Project overview (allowed in root)
โโโ CHANGELOG.md # Version history (allowed in root)
โโโ AGENTS.md # AI assistant rules (allowed in root)
โโโ LICENSE # Project license (allowed in root)
โโโ CONTRIBUTING.md # Contribution guidelines (allowed in root)
โโโ CODE_OF_CONDUCT.md # Code of conduct (allowed in root)
โโโ SECURITY.md # Security policy (allowed in root)
โโโ docs/ # All other documentation
โโโ ROADMAP.md # Implementation timeline
โโโ DAG.md # Component dependencies
โโโ ARCHITECTURE.md # System design
โโโ specs/ # Feature specifications
โโโ guides/ # Developer guides
โโโ diagrams/ # Architecture diagrams
โโโ benchmarks/ # Performance results
โโโ versions/ # Release reportsTesting Requirements
All projects using rulebook must follow these testing standards:
- Minimum Coverage: Configurable (default 95%)
- Test Location:
/testsdirectory in project root - Test Execution: 100% of tests must pass before next task
- Test-Driven: Write tests before implementation
Rules Ignore
Create a .rulesignore file to selectively disable rules:
# Ignore coverage requirement
coverage-threshold
# Ignore specific language rules
rust/edition-2024
# Ignore all TypeScript rules
typescript/*
# Use glob patterns
*-thresholdGenerated Workflows (35 total)
When workflow generation is enabled, rulebook creates GitHub Actions workflows:
Test & Lint Workflows (21)
- Rust: rust-test.yml, rust-lint.yml
- TypeScript: typescript-test.yml, typescript-lint.yml
- Python: python-test.yml, python-lint.yml
- Go: go-test.yml, go-lint.yml
- Java: java-test.yml, java-lint.yml
- Elixir: elixir-test.yml, elixir-lint.yml
- C#: dotnet-test.yml, dotnet-lint.yml
- PHP: php-test.yml, php-lint.yml
- Swift: swift-test.yml, swift-lint.yml
- Kotlin: kotlin-test.yml, kotlin-lint.yml
- Universal: codespell.yml (typo detection)
Publishing Workflows (10)
- TypeScript: typescript-publish.yml โ npm (with provenance)
- Rust: rust-publish.yml โ crates.io
- Python: python-publish.yml โ PyPI (trusted publishing)
- Go: go-publish.yml โ pkg.go.dev
- Java: java-publish.yml โ Maven Central + GitHub Packages
- Elixir: elixir-publish.yml โ Hex.pm
- C#: dotnet-publish.yml โ NuGet
- PHP: php-publish.yml โ Packagist (auto-sync validation)
- Swift: swift-publish.yml โ Swift Package Manager
- Kotlin: kotlin-publish.yml โ Maven Central
Git Workflow (1)
- Complete Git workflow guidelines with quality gates and CI/CD monitoring
Example AGENTS.md Output
<!-- RULEBOOK:START -->
# Project Rules
## Documentation Standards
**CRITICAL**: Minimize Markdown files. Keep documentation organized.
## Testing Requirements
- **Minimum Coverage**: 95%
- **Test Location**: `/tests` directory
- **Test Execution**: 100% pass rate required
## Feature Development Workflow
1. Check specifications in `/docs/specs/`
2. Implement with tests
3. Run quality checks
4. Update documentation
<!-- RULEBOOK:END -->
<!-- RUST:START -->
# Rust Project Rules
[Rust-specific rules...]
<!-- RUST:END -->
<!-- VECTORIZER:START -->
# Vectorizer Instructions
[Vectorizer usage patterns...]
<!-- VECTORIZER:END -->Development
# Install dependencies
npm install
# Run in development
npm run dev
# Build
npm run build
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Lint
npm run lint
# Format
npm run formatRequirements
- Node.js 18.0.0 or higher
- npm 9.0.0 or higher
License
MIT
Contributing
Contributions are welcome! Please read our contributing guidelines and code of conduct.
Support
- ๐ Documentation
- ๐ Issue Tracker
- ๐ฌ Discussions
Credits
Created by the HiveLLM Team to standardize AI-assisted development workflows.