Guidelines for getting the most out of @hivellm/rulebook.
Set up rulebook at the start of your project:
# Right after creating project
cargo new my-project
cd my-project
npx @hivellm/rulebook initWhy: Establishes standards before code is written, preventing technical debt.
Always commit AGENTS.md to version control:
git add AGENTS.md
git commit -m "Add rulebook standards"Why: Ensures all team members and AI assistants follow the same rules.
Only ignore rules when absolutely necessary:
# Good: Specific exception with reason
coverage-threshold # Legacy code, improving gradually
# Bad: Ignoring entire languages
typescript/*
Why: More rules = better code quality and consistency.
Explicitly mention AGENTS.md in your requests:
@AGENTS.md Implement user authentication following our standards
Why: Ensures AI follows project-specific rules.
Ask AI to verify compliance:
Review this code against @AGENTS.md standards
Why: Catches violations before they reach code review.
Reference AGENTS.md in PR reviews:
This doesn't follow our testing requirements in AGENTS.md.
Please add tests to meet 95% coverage threshold.
Why: Consistent, documented standards for reviews.
Follow test-driven development:
// 1. Write test
#[test]
fn test_user_creation() {
let user = create_user("test@example.com");
assert_eq!(user.email, "test@example.com");
}
// 2. Implement feature
fn create_user(email: &str) -> User {
// Implementation
}Why: Ensures complete test coverage and clear requirements.
Always meet or exceed the configured threshold:
# Check coverage
cargo llvm-cov # Rust
npm run test:coverage # TypeScript
pytest --cov # Python
# Must be >= 95% (or configured threshold)Why: High coverage reduces bugs and improves maintainability.
Don't just test happy paths:
describe('validateEmail', () => {
it('accepts valid email', () => { ... });
it('rejects empty string', () => { ... });
it('rejects missing @', () => { ... });
it('rejects invalid TLD', () => { ... });
it('handles unicode characters', () => { ... });
});Why: Edge cases are where bugs hide.
Keep documentation organized with allowed root files and /docs:
root/
├── README.md # Overview (allowed)
├── CHANGELOG.md # History (allowed)
├── AGENTS.md # AI rules (allowed)
├── LICENSE # License (allowed)
├── CONTRIBUTING.md # Contributing (allowed)
├── CODE_OF_CONDUCT.md # Conduct (allowed)
├── SECURITY.md # Security (allowed)
└── docs/ # All other docs
├── ROADMAP.md
├── ARCHITECTURE.md
├── specs/
├── guides/
└── diagrams/
Why: Easy to find documentation, reduces clutter, follows open source standards.
Don't let documentation fall behind:
# After implementing feature
1. Update /docs/ROADMAP.md (mark as complete)
2. Update /docs/specs/feature.md (actual implementation)
3. Update CHANGELOG.md (note changes)Why: Stale documentation is worse than no documentation.
Use Architecture Decision Records (ADRs):
# docs/decisions/001-use-tokio.md
## Context
Need async runtime for server.
## Decision
Use Tokio instead of async-std.
## Consequences
+ Industry standard
+ Large ecosystem
- Slightly more complexWhy: Preserves reasoning for future developers.
Before adding dependencies:
# In AI assistant
Use Context7 to check latest version of tokio
Add tokio with recommended features
Document why we chose tokioWhy: Latest versions have security fixes and improvements.
Add comments in dependency files:
# Cargo.toml
[dependencies]
# Using 1.35 for new tokio::select! macro
tokio = { version = "1.35", features = ["full"] }Why: Helps future maintainers understand constraints.
Keep dependencies current:
# Monthly dependency updates
cargo update # Rust
npm update # TypeScript
poetry update # PythonWhy: Prevents accumulation of breaking changes.
Fix all linter warnings:
# Must pass with no warnings
cargo clippy --workspace -- -D warnings
npm run lint
ruff check .Why: Warnings become technical debt quickly.
Always format code:
# Git pre-commit hook
cargo +nightly fmt --all
npm run format
ruff format .Why: Consistent formatting reduces diff noise.
Set up CI/CD to enforce standards:
# .github/workflows/quality.yml
- name: Check formatting
run: cargo +nightly fmt --all -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test
- name: Check coverage
run: cargo llvm-cov --fail-under-lines 95Why: Automated enforcement prevents violations.
Use for codebase exploration:
Use Vectorizer to find all authentication implementations
Use Vectorizer to get project outline
Use Vectorizer to find files related to user management
Why: Faster than manual file searching.
Use for task tracking:
Store current task in Synap: synap_kv_set("task:current", {...})
Track test results in Synap
Store session state before context switch
Why: Preserves state across context windows.
Use for significant changes:
Create OpenSpec proposal for new API design
Review existing specs before implementing
Update specs with actual implementation
Why: Structured planning prevents mistakes.
Use for dependencies:
Check Context7 for latest axum version
Review Context7 docs for axum routing best practices
Verify security advisories in Context7
Why: Up-to-date information prevents issues.
Ensure all team members use the same AGENTS.md:
# Pull latest rules
git pull origin main
# Verify AGENTS.md is current
git log -1 AGENTS.mdWhy: Consistency across team.
Update rules through pull requests:
# Create branch
git checkout -b update-coverage-threshold
# Update AGENTS.md
npx @hivellm/rulebook init
# Commit and PR
git commit -am "Increase coverage threshold to 98%"Why: Allows team discussion and review.
When using .rulesignore, document why:
# .rulesignore
# Legacy auth module has 78% coverage
# See issue #123 for improvement plan
auth/legacy/*
Why: Prevents cargo-cult rule ignoring.
Review and update rules quarterly:
# Every quarter
npx @hivellm/rulebook init
# Review new features
# Update thresholds if team improved
# Add new modules if adoptedWhy: Rules evolve with project maturity.
Track metrics:
- Bug count before/after rulebook
- Code review time
- Time to onboard new developers
- Test coverage trends
Why: Data-driven improvement.
Document what works:
# docs/guides/lessons-learned.md
## What Worked
- 95% coverage caught 3 major bugs early
- Strict docs made onboarding 50% faster
- .rulesignore helped with legacy code
## What Didn't
- 100% coverage was too strict for utils
- Enforcing all clippy lints created noiseWhy: Helps other teams and projects.
# .rulesignore
* # DON'T DO THIS
Why: Defeats the purpose of rulebook.
# Last updated 2 years ago
git log -1 AGENTS.mdWhy: Stale rules are misleading.
# Some files follow rules, some don't
Why: Partial compliance is confusing.
Ignore AGENTS.md, just make it work
Why: Bypasses quality standards.
- ✅ Initialize early in project lifecycle
- ✅ Commit AGENTS.md to version control
- ✅ Write tests first, meet coverage thresholds
- ✅ Keep documentation current in /docs
- ✅ Use Context7 for dependency management
- ✅ Enforce quality with CI/CD
- ✅ Leverage MCP modules (Vectorizer, Synap, etc.)
- ✅ Review and update rules regularly
- ✅ Measure impact and improve
- ✅ Document exceptions and learnings