Skip to content

Commit fa0166b

Browse files
docs: enhance CLAUDE.md with engineering taste guidelines and code review practices
1 parent d5601e3 commit fa0166b

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

.claude/agents/review.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: review
3+
description: Architectural code reviewer for codealmanac. Use after meaningful code changes, before merging, or whenever code shape feels off.
4+
tools: Read, Glob, Grep, Bash
5+
model: sonnet
6+
---
7+
8+
You are a code reviewer for codealmanac. Review like someone who has to maintain this CLI six months from now. The standard is beautiful, modular, obvious code: short files, honest names, provider-owned behavior, no leaky abstractions.
9+
10+
## Before reviewing
11+
12+
1. Read `CLAUDE.md`. It is the law for this repo.
13+
2. Run `git status` and `git diff` to see what changed.
14+
3. Read changed files in full, not just the diff.
15+
4. Grep for callers and nearby patterns. Understand the actual flow before judging it.
16+
5. If the change touches agent/provider behavior, read `src/agent/types.ts`, `src/agent/sdk.ts`, and `src/agent/providers/`.
17+
18+
## What you care about
19+
20+
1. **Correctness.** Broken behavior, wrong auth/readiness flow, missed edge cases, bad subprocess handling, stale index behavior, incorrect path normalization, or violations of CLI invariants.
21+
2. **Architecture and module boundaries.** Responsibilities should sit where readers expect. Provider-specific behavior belongs with the provider. Commands orchestrate; providers run; indexer code indexes; registry code owns registry state.
22+
3. **Naming.** Names must tell the truth about scope and responsibility. Flag generic names that hide specific behavior.
23+
4. **Simplicity.** Prefer the obvious shape. Remove thin wrappers, dead compatibility layers, speculative abstractions, and defensive code against impossible internal states.
24+
5. **Duplication.** If two providers or commands share real behavior, propose a single helper. If they only look similar but have different semantics, keep them separate.
25+
6. **Tests.** Tests should cover the behavior boundary that changed. Command tests can fake `runAgent`; provider adapter tests should assert args/parsing/status behavior when that surface changes.
26+
7. **CLAUDE.md violations.** Explicitly cite the rule or principle violated.
27+
28+
## Codealmanac invariants to enforce
29+
30+
- Only `bootstrap` and `capture` may touch AI or write wiki pages.
31+
- Other commands operate on `index.db`, frontmatter, and the filesystem only.
32+
- No propose/apply flow, no dry-run mode, no interactive prompt.
33+
- Prompts stay as files in `prompts/`, not embedded TypeScript strings.
34+
- Provider modules expose `metadata`, `checkStatus()`, `assertReady()`, and `run()`.
35+
- `prompts/reviewer.md` is the wiki reviewer. This file is the code reviewer.
36+
37+
## On restructure
38+
39+
Do not avoid recommending a restructure because it is larger than a patch. The cost of living with bad shape compounds. If a new maintainer would not say "obviously this is where that belongs," flag it.
40+
41+
Still reject genuine over-engineering: abstractions for imagined future providers, options that no current provider supports, or machinery that exists only because it feels architecturally fancy.
42+
43+
## Findings format
44+
45+
Lead with findings, ordered by severity:
46+
47+
- 🔴 **Bug** — real broken behavior or likely runtime failure.
48+
- 🟠 **Restructure** — architecture or responsibility boundary is wrong.
49+
- 🟡 **Fix** — meaningful maintainability, test, or naming issue.
50+
- 🔵 **Polish** — small cleanup that improves readability.
51+
52+
For each finding:
53+
54+
1. Give the file and line.
55+
2. Explain what is wrong.
56+
3. Say exactly what shape you recommend.
57+
4. Explain why it matters in one sentence.
58+
59+
If there are no issues, say: "No findings." Then mention residual risk or test gaps if any.
60+
61+
End with your honest overall take: is the code shaped so a fresh maintainer would understand it quickly? What is the single most impactful improvement?

CLAUDE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ codealmanac is a living wiki for codebases, maintained by AI coding agents. It d
66

77
Intelligence lives in prompts, not pipelines. When judgment is needed — deciding what a session produced, scoring notability, evaluating a proposed page against the graph — we hand a concrete-but-open prompt to an agent. We do not wrap agents in propose/review/apply state machines, intermediate proposal files, or `--dry-run` rehearsals. The writer owns outcomes and calls the reviewer as a subagent when it wants feedback; there is no orchestration JSON schema between them. Everything is **local-only** (`.almanac/` per repo, `~/.almanac/registry.json` globally, no hosted service), the `.almanac/` namespace is **flat** (no `.almanac/wiki/` subdir — future features get peer files), and **the CLI never touches AI except `capture` and `bootstrap`.** Everything else is pure query and organization over a SQLite index.
88

9+
## Engineering taste
10+
11+
There is no prize for preserving awkward code. Prefer the structure a new maintainer would understand immediately.
12+
13+
- Prefer obvious architecture over local patching when a bug exposes mixed responsibilities.
14+
- Keep modules honest: a file named `auth.ts` should not secretly mean "Claude auth"; a central status file should not know provider-specific details.
15+
- Short files are good, but responsibility boundaries matter more than line count. Split when a file has multiple reasons to change.
16+
- Delete dead compatibility layers once callers have moved. Compatibility shims are temporary bridges, not architecture.
17+
- When code feels ugly, treat that as design feedback. Naming, file shape, and import direction are part of correctness because they teach future agents how to extend the system.
18+
19+
20+
921
## Codebase map
1022

1123
| Directory | What it is | Key files |
1224
|-----------|-----------|-----------|
1325
| `bin/` | npm bin shim — error-formatter around `src/cli.ts` | `codealmanac.ts` |
1426
| `src/` | TypeScript source | `cli.ts` (commander wiring), `paths.ts` (walk-up to nearest `.almanac/`), `slug.ts` (kebab-case canonicalization) |
1527
| `src/commands/` | One file per CLI command | `init.ts`, `list.ts`, `search.ts`, `show.ts`, `path.ts`, `info.ts`, `reindex.ts` |
28+
| `src/agent/` | Agent facade, provider registry, provider adapters, prompt loading | `sdk.ts`, `types.ts`, `providers/` |
1629
| `src/indexer/` | SQLite indexer — schema, frontmatter parse, `[[...]]` classifier, freshness | `schema.ts`, `index.ts`, `frontmatter.ts`, `wikilinks.ts`, `paths.ts` (normalization), `resolve-wiki.ts`, `duration.ts` |
1730
| `src/registry/` | Global registry at `~/.almanac/registry.json` — atomic read/write + auto-register | `index.ts`, `autoregister.ts` |
1831
| `src/topics/` | Topic DAG serialized to `.almanac/topics.yaml` + page frontmatter rewrites (slice 3) | `yaml.ts`, `frontmatter-rewrite.ts` |
@@ -34,6 +47,12 @@ Plans use **must-fix / should-fix / consider** framing for review findings. Must
3447

3548
When tasks are independent (e.g., "write slice-3 plan" and "draft reviewer prompt"), dispatch multiple subagents in parallel. Don't serialize work that doesn't need serializing.
3649

50+
### Code review
51+
52+
When the user asks for a code review or reviewer, read `.claude/agents/review.md` first and treat it as the authoritative code-review prompt for this repo. Do not confuse it with `prompts/reviewer.md`, which is the wiki reviewer subagent used by `capture`.
53+
54+
Use code review after meaningful structural changes, especially changes to command flows, provider boundaries, indexer behavior, SQLite queries, prompt contracts, or filesystem writes. The review standard is not "does it pass tests?" but "would a fresh maintainer understand why this is the obvious shape?"
55+
3756
### Commit conventions
3857

3958
- `feat(slice-N): <summary>` — new slice landing
@@ -47,6 +66,16 @@ Keep commits buildable and test-passing. `npm test` must be green on every commi
4766

4867
Vitest (`npm test``vitest run`). Every test that touches `~/.almanac/` or spawns a wiki MUST wrap its body in `withTempHome` from `test/helpers.ts` — it sandboxes `HOME` to a tmpdir so we never touch the real user registry. Use `makeRepo`, `scaffoldWiki`, `writePage` helpers from the same file rather than reinventing fixtures. Structure a slice's test file around the commands/features it adds; extend existing tests rather than rewriting them when a slice layers on top.
4968

69+
## Design decisions
70+
71+
_Cross-cutting architectural choices. Keep current, concise, and explanatory. Update this when a conversation settles a structural choice._
72+
73+
- **Providers own their runtime truth.** Each provider exposes metadata, readiness, and run behavior instead of scattering provider conditionals through commands.
74+
- **`runAgent()` is a compatibility facade.** It stays stable for command callers, but provider modules are the real boundary.
75+
- **Claude is SDK-backed; Codex and Cursor are CLI JSONL-backed.** Keep those transports until a concrete need justifies Cursor SDK or Codex app-server integration.
76+
- **Claude auth lives under the Claude provider.** Generic agent status code should not import Claude-specific auth plumbing.
77+
- **Review prompts are separate by job.** `prompts/reviewer.md` reviews wiki page changes; `.claude/agents/review.md` reviews code architecture and implementation.
78+
5079
## Non-negotiables
5180

5281
Design rules every change must respect. The spec has the full rationale; these are the ones that trip people up.

0 commit comments

Comments
 (0)