feat: Add SOLID principles and TDD reference documentation
- Created solid.md to document the SOLID principles for clean code practices. - Created tdd.md to outline Test Driven Development principles and practices. - Added kana-rust-backend-best-practice.md as a reference guide for building a Rust backend using Axum and SeaORM. - Established push-flow-convention.md to enforce pre-commit and pre-push hooks with versioning rules. - Introduced AGENTS.md to provide guidance on best practices and available commands for Kilo. - Configured kilo.json to include new skills and agents for enhanced functionality. - Added lefthook.yml for managing git hooks to ensure code quality and adherence to conventions.
This commit is contained in:
@@ -46,7 +46,77 @@ Detailed architecture documentation is in `docs/CODEMAPS/`:
|
||||
- **Auto inline review** after each edit: `src/app/subagent/auto.rs` — `spawn_quick_review()` injects verdict back into LLM conversation.
|
||||
- **Background subagents** (test-gen, arch-review, security-review) fire asynchronously at turn end via `TurnEvent::SystemNote`, retrying once on failure and escalating to a blocking (`ESCALATED:`-prefixed, `ToastKind::Error`) notice if the retry also fails.
|
||||
|
||||
Commit convention (Conventional Commits, Bahasa Indonesia): see the `commit-convention` skill.
|
||||
---
|
||||
|
||||
## Best Practices (Kana Engineering Standards)
|
||||
|
||||
This project follows Kana Engineering Best Practices. The following skills are loaded and enforced:
|
||||
|
||||
| Skill | Location | Purpose |
|
||||
|-------|----------|---------|
|
||||
| `clean-code` | `.claude/skills/clean-code/SKILL.md` | Clean Code principles (naming, functions, classes, comments) |
|
||||
| `commit-convention` | `.claude/skills/commit-convention/SKILL.md` | Conventional Commits (Bahasa Indonesia) |
|
||||
| `push-flow-convention` | `.claude/skills/push-flow-convention/SKILL.md` | Pre-commit/pre-push hooks via lefthook |
|
||||
| `kana-rust-backend-best-practice` | `.claude/skills/kana-rust-backend-best-practice/SKILL.md` | Rust clean-architecture patterns (Axum, SeaORM, etc.) |
|
||||
|
||||
### Layering Rules
|
||||
|
||||
```
|
||||
domain/ → application/ → infrastructure/ → interfaces/ → gateway/
|
||||
(inward) (outward)
|
||||
```
|
||||
|
||||
- **Domain** (Layer 0): Pure entities, value objects, repository/service traits. ZERO external framework deps.
|
||||
- **Application** (Layer 1): Use-case services (one per file), port traits. Depends ONLY on domain.
|
||||
- **Infrastructure** (Layer 2): Concrete implementations of domain traits (SQLite, JSON files, LLM clients, LSP servers, MCP).
|
||||
- **Interfaces** (Layer 3): Presentation adapters — TUI (ratatui), API (Axum), WebSocket, daemon, gRPC, web.
|
||||
- **Gateway**: Composition root — the only place that wires all layers together.
|
||||
|
||||
**Critical:** Domain must NEVER import application, infrastructure, or interfaces. Application must NEVER import infrastructure or interfaces.
|
||||
|
||||
### Commit Convention (Bahasa Indonesia)
|
||||
|
||||
All commits follow Conventional Commits in Bahasa Indonesia:
|
||||
|
||||
```
|
||||
feat(tool): add batch file delete
|
||||
fix(ipc): reconnect loop on socket timeout
|
||||
chore: bump reqwest to 0.13
|
||||
docs: add architecture diagram to README
|
||||
refactor(harness): flatten guard pipeline
|
||||
```
|
||||
|
||||
Types: `feat`, `fix`, `chore`, `docs`, `refactor`, `test`, `style`, `perf`, `ci`. All types produce a release (patch minimum). Add `BREAKING CHANGE:` for major bumps.
|
||||
|
||||
### Clean Code Principles
|
||||
|
||||
- **Functions under ~40 lines**, one level of abstraction, extracted till you drop.
|
||||
- **No flag arguments** — split `render(true)` into `renderForSuite()` / `renderForSingleTest()`.
|
||||
- **Command-Query Separation** — function either does or answers, never both.
|
||||
- **No switch/if-else on type** — replace with factory + polymorphism.
|
||||
- **No null returns** — use `Option<T>` or empty collections.
|
||||
- **No magic numbers** — extract named constants.
|
||||
- **DRY** — no duplication.
|
||||
- **Tell, Don't Ask** — don't fetch state then decide; tell the object to work.
|
||||
- **Boy Scout Rule** — leave every module cleaner than you found it.
|
||||
|
||||
### Error Handling
|
||||
|
||||
- `anyhow::Result` and `anyhow::bail!` throughout (except domain layer typed errors).
|
||||
- `tracing::warn!` / `tracing::error!` for logging. NEVER stderr (corrupts TUI).
|
||||
- Never `.unwrap()` or `.expect()` in production code — use `?` or proper error handling.
|
||||
- Log expected failures at `warn!`, unexpected errors at `error!`.
|
||||
|
||||
### Testing
|
||||
|
||||
- `#[cfg(test)] mod tests` blocks inline in production files.
|
||||
- Tests are F.I.R.S.T. — Fast, Independent, Repeatable, Self-validating, Timely.
|
||||
- Use `Result<()>` as test return type for `?` propagation.
|
||||
- Mock at boundaries only; prefer fakes for owned abstractions.
|
||||
|
||||
### Compiler Bypasses
|
||||
|
||||
NEVER use `#[allow(...)]`, `#[expect(...)]`, or `#[allow(dead_code)]`. Fix the underlying code instead.
|
||||
|
||||
## Code Documentation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user