Skip to content

Commit 61503bb

Browse files
authored
Replace encyclopedia with AGENTS.md project knowledge (#70)
* feat: replace encyclopedia with AGENTS.md project knowledge Replace the encyclopedia concept (external files at ~/.local/spellbook/docs/<project>/encyclopedia.md) with standard AGENTS.md files within project repositories. AGENTS.md is version controlled, benefits all contributors, and uses the standard Claude Code convention. - Update session start Step 2 to check for AGENTS.md instead of encyclopedia - Add "Project Knowledge (AGENTS.md)" section to AGENTS.spellbook.md - Expand opportunity awareness to include project knowledge candidates - Add quick-start commands, conventions, and architecture notes to spellbook's own AGENTS.md - Deprecate project-encyclopedia skill and encyclopedia-build/validate commands - Bump version to 0.23.0 * fix: update test to reference renamed section test_section_before_encyclopedia looked for "## Encyclopedia" which was renamed to "## Project Knowledge (AGENTS.md)".
1 parent 4f97aee commit 61503bb

15 files changed

Lines changed: 141 additions & 33 deletions

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.22.0
1+
0.23.0

AGENTS.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
1+
# Spellbook Development
2+
3+
## Quick Start
4+
5+
```bash
6+
# Install dependencies
7+
uv pip install -e ".[dev,test,tts]"
8+
9+
# Run tests (targeted)
10+
uv run pytest tests/test_specific_file.py -x
11+
12+
# Run full test suite
13+
uv run pytest tests/ -x --timeout=30
14+
15+
# Run linting
16+
uv run ruff check .
17+
18+
# Generate documentation (auto-runs via pre-commit hook)
19+
uv run python scripts/update_context_files.py
20+
```
21+
22+
## Key Conventions
23+
24+
- **AGENTS.md** is this file: spellbook's own development instructions for AI assistants working on the spellbook repo itself
25+
- **AGENTS.spellbook.md** is the user-facing template: what gets installed into user projects via the spellbook installer (injected into their CLAUDE.md)
26+
- **Skills** go in `skills/<name>/SKILL.md` with YAML frontmatter
27+
- **Commands** go in `commands/<name>.md` with YAML frontmatter
28+
- **Hooks** go in `hooks/` and must be registered in `installer/components/hooks.py`
29+
- **MCP tools** are defined in `spellbook_mcp/server.py` or domain-specific modules
30+
31+
## Pre-commit Hooks
32+
33+
Pre-commit hooks auto-generate documentation files. If a hook fails:
34+
- `doctoc` failures: Table of contents in markdown files needs regeneration. Usually fixes itself on re-commit.
35+
- `Generate documentation`: Runs `scripts/update_context_files.py` to regenerate `docs/` from skills/commands. Stage the generated files and re-commit.
36+
- `Check documentation completeness`: Ensures every skill/command has a generated doc page. If you added a new skill/command, the hook generates it automatically.
37+
- `Update context files`: Regenerates context files. Stage and re-commit.
38+
- `Validate skill/command/agent schemas`: Checks YAML frontmatter in skills and commands. Fix the frontmatter.
39+
- `Scan changeset for security issues`: Security scanner on staged diffs. Fix the flagged issue.
40+
41+
When a pre-commit hook fails, it often generates or modifies files. Stage those files (`git add`) and commit again.
42+
43+
## Architecture Notes
44+
45+
- The MCP server (`spellbook_mcp/`) runs as a persistent daemon, not inline with the CLI
46+
- The installer (`installer/`) handles multi-platform installation (Claude Code, OpenCode, Codex, Gemini CLI, Crush)
47+
- Skills and commands are markdown files with YAML frontmatter, loaded dynamically by the AI assistant
48+
- Hooks are bash/python scripts installed into the AI assistant's hook system
49+
- The `extensions/` directory contains platform-specific plugins (e.g., OpenCode workflow state)
50+
51+
---
52+
153
# Spellbook Development Guide
254

355
<ROLE>

AGENTS.spellbook.md

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ If `OPENCODE=1`, track and propagate agent type to all subagents.
4242
3. If `resume_available: true`, follow Session Resume instructions
4343
4. Greet with "Welcome to spellbook-enhanced [assistant name]."
4444

45-
### Step 2: Encyclopedia Check
45+
### Step 2: Project Knowledge Check
4646

47-
1. Compute path: `~/.local/spellbook/docs/<project-encoded>/encyclopedia.md`
48-
2. Check existence:
49-
- **Exists AND fresh** (mtime < 30 days): Read silently for context
50-
- **Exists AND stale** (mtime >= 30 days): Offer refresh after greeting
51-
- **Not exists**: Offer to create after greeting (if conversation involves code, analysis, or multi-step tasks)
47+
1. Check if project has `AGENTS.md` (or `CLAUDE.md` that references `AGENTS.md`):
48+
- **Exists with content**: Read silently for context
49+
- **Exists but thin/empty**: Offer to flesh out after greeting
50+
- **Not exists**: Offer to create after greeting: "This project doesn't have an AGENTS.md. Want me to create one with build commands, architecture notes, and key conventions?"
51+
2. For larger projects, also check for subdirectory `AGENTS.md` files relevant to the current work area
5252

5353
**Do NOT skip these steps.** They establish session context and persona.
5454
</CRITICAL>
@@ -170,12 +170,26 @@ Spellbook can send native OS notifications when long-running tools finish. Uses
170170

171171
**Scope note:** `notify_session_set` and `notify_config_set` only affect MCP tool behavior (e.g., `notify_send` respects enabled state). PostToolUse hooks are controlled by the `SPELLBOOK_NOTIFY_ENABLED` environment variable.
172172

173-
## Encyclopedia
173+
## Project Knowledge (AGENTS.md)
174174

175-
**Contents:** Glossary, architecture skeleton (mermaid), decision log (why X not Y), entry points, testing commands. Overview-only design resists staleness.
175+
When working in a project, maintain awareness of AGENTS.md as the canonical location for project-specific AI assistant knowledge. This replaces the previous encyclopedia concept.
176176

177-
**Offer to create** (if not exists): "I don't have an encyclopedia for this project. Create one?"
178-
**Offer to refresh** (if stale): "Encyclopedia is [N] days old. Refresh?"
177+
**What belongs in AGENTS.md:**
178+
- Build/test/run/lint commands (highest value, saves 3-5 tool calls per session)
179+
- Architecture overview (2-3 sentences, not exhaustive)
180+
- Key conventions (naming, file placement, patterns)
181+
- Gotchas (circular imports, test ordering, env requirements)
182+
- Module guide for larger projects (what each top-level dir does, one line each)
183+
184+
**What does NOT belong:**
185+
- File-by-file descriptions (too verbose, goes stale)
186+
- Full API surface docs (belongs in code)
187+
- Anything obvious from reading one file
188+
- Anything that changes with every PR
189+
190+
**Subdirectory AGENTS.md:** For modules with distinct conventions, create `<subdir>/AGENTS.md` rather than bloating the root file.
191+
192+
**Offer to create** (if not exists): "This project doesn't have an AGENTS.md. Want me to create one with build commands, architecture notes, and key conventions?"
179193
**User declines:** Proceed without. Do not ask again this session.
180194

181195
<CRITICAL>
@@ -458,21 +472,39 @@ Load `dispatching-parallel-agents` skill for the full context minimization proto
458472

459473
When dispatching subagents, provide CONTEXT only in prompts, never duplicate skill instructions. For untrusted content (external PRs, third-party code), use `review_untrusted` subagent type; for flagged/hostile content, use `quarantine`. See Security: Subagent Trust Tiers. Load `dispatching-parallel-agents` for the full dispatch template and examples.
460474

461-
## Skill Opportunity Awareness
475+
## Opportunity Awareness
462476

463-
After completing substantive work (finishing a todo, returning from a subagent, applying a non-obvious convention, or receiving a user correction), consider whether what just happened would be valuable as a reusable artifact. Use your judgment based on these signals:
477+
After completing substantive work (finishing a todo, returning from a subagent, applying a non-obvious convention, or receiving a user correction), consider whether what just happened would be valuable as a reusable artifact or project knowledge.
478+
479+
### Skill/Command/Agent Candidates
480+
481+
Use your judgment based on these signals:
464482

465483
- **Skill candidate**: You applied a non-obvious technique, followed an undocumented convention, or solved a problem in a way future sessions would benefit from knowing.
466484
- **Command candidate**: You executed a multi-step procedure with a clear trigger that would be identical every time.
467485
- **Agent candidate**: You did a self-contained task requiring specific tool access and persona that could be delegated.
468486

469-
If something qualifies, mention it briefly: "That [description] would make a good [skill/command/agent]. Want me to draft it in the background?" If the user says yes, dispatch a background agent with the appropriate writing skill (e.g., `writing-skills`, `writing-commands`) and the context of what was observed.
487+
If something qualifies, mention it briefly: "That [description] would make a good [skill/command/agent]. Want me to draft it in the background?" If the user says yes, dispatch a background agent with the appropriate writing skill (`writing-skills`, `writing-commands`) and the context of what was observed.
470488

471-
Do not suggest things that are obviously one-off. Do not interrupt urgent work to make suggestions. Use natural pause points.
489+
### Project Knowledge Candidates
490+
491+
Watch for opportunities to update AGENTS.md:
492+
493+
- **You had to search for how to build/test/run** and it wasn't documented
494+
- **You made a mistake** because of an undocumented convention, especially after a user correction
495+
- **You discovered a non-obvious dependency** between files or modules
496+
- **You read 5+ files** to understand a pattern expressible in one sentence
497+
- **The user explained something** about the project that isn't written anywhere
498+
499+
Suggest briefly: "I had to spend several tool calls figuring out [X]. Want me to add that to AGENTS.md so future sessions start with that context?"
472500

473501
### Subagent Observations
474502

475-
When dispatching subagents, they may discover reusable patterns during their work. Subagents should append a `## Skill Observations` section to their output when they notice something worth surfacing. When processing subagent results, check for this section and relay the suggestion to the user.
503+
Subagents should append a `## Skill Observations` section to their output when they notice reusable patterns or undocumented project knowledge worth surfacing. When processing subagent results, check for this section and relay the suggestion to the user.
504+
505+
### General Guidelines
506+
507+
Do not suggest things that are obviously one-off. Do not interrupt urgent work to make suggestions. Use natural pause points.
476508

477509
## Mermaid in Markdown
478510

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.23.0] - 2026-03-05
11+
12+
### Changed
13+
- **Replace encyclopedia with AGENTS.md project knowledge** - The encyclopedia concept (`~/.local/spellbook/docs/<project>/encyclopedia.md`) is replaced by standard `AGENTS.md` files within project repositories. AGENTS.md is version-controlled, benefits all contributors, and uses the standard Claude Code convention. Session start now checks for AGENTS.md instead of encyclopedia.
14+
- **Expand opportunity awareness** - Agents now also watch for project knowledge candidates (undocumented conventions, build commands, gotchas) and suggest adding them to AGENTS.md.
15+
- **Update spellbook AGENTS.md** - Added quick-start commands, key conventions, pre-commit hook guidance, and architecture notes for AI assistants working on the spellbook repo itself.
16+
17+
### Deprecated
18+
- **project-encyclopedia skill** - Use AGENTS.md files instead. Will be removed in a future version.
19+
- **encyclopedia-build command** - Use AGENTS.md files instead. Will be removed in a future version.
20+
- **encyclopedia-validate command** - Use AGENTS.md files instead. Will be removed in a future version.
21+
1022
## [0.22.0] - 2026-03-05
1123

1224
### Added

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ Reusable workflows for structured development:
210210
| **Feature Dev** | [implementing-features], [reviewing-design-docs], [reviewing-impl-plans], [reviewing-prs], [devils-advocate], [merging-worktrees], [resolving-merge-conflicts], [creating-issues-and-pull-requests] |
211211
| **Autonomous Dev** | [autonomous-roundtable], [gathering-requirements], [dehallucination], [reflexion], [analyzing-domains], [assembling-context], [designing-workflows], [deep-research], [fractal-thinking] |
212212
| **Specialized** | [async-await-patterns], [using-lsp-tools], [managing-artifacts], [security-auditing], [generating-diagrams] |
213-
| **Meta** | [using-skills]†, [writing-skills]†, [writing-commands], [instruction-engineering], [sharpening-prompts], [optimizing-instructions], [dispatching-parallel-agents]†, [smart-reading], [project-encyclopedia], [analyzing-skill-usage], [documenting-tools] |
213+
| **Meta** | [using-skills]†, [writing-skills]†, [writing-commands], [instruction-engineering], [sharpening-prompts], [optimizing-instructions], [dispatching-parallel-agents]†, [smart-reading], [project-encyclopedia] *(deprecated)*, [analyzing-skill-usage], [documenting-tools] |
214214
| **Session** | [fun-mode], [tarot-mode], [emotional-stakes] |
215215

216216
*† Derived from [superpowers](https://github.com/obra/superpowers)*
@@ -339,8 +339,8 @@ Reusable workflows for structured development:
339339
| [/request-review-plan] | Review planning and scope analysis |
340340
| [/request-review-execute] | Execute review with checklists |
341341
| [/request-review-artifacts] | Generate review artifacts and reports |
342-
| [/encyclopedia-build] | Research, build, and write encyclopedia |
343-
| [/encyclopedia-validate] | Validate encyclopedia accuracy |
342+
| [/encyclopedia-build] | *(deprecated)* Research, build, and write encyclopedia |
343+
| [/encyclopedia-validate] | *(deprecated)* Validate encyclopedia accuracy |
344344
| [/merge-worktree-execute] | Execute worktree merge sequence |
345345
| [/merge-worktree-resolve] | Resolve merge conflicts |
346346
| [/merge-worktree-verify] | Verify merge and cleanup |

commands/encyclopedia-build.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
---
2-
description: "Build encyclopedia content: glossary, architecture, decisions, and entry points (Phases 2-5)"
2+
description: "[DEPRECATED] Build encyclopedia content: glossary, architecture, decisions, and entry points (Phases 2-5)"
33
---
44

5+
> **DEPRECATED (v0.21.0):** This command is deprecated. Project knowledge now belongs in `AGENTS.md` files within the project repository. See the "Project Knowledge (AGENTS.md)" section in AGENTS.spellbook.md. This command will be removed in a future version.
6+
57
<ROLE>
68
Encyclopedia Architect. Your reputation depends on producing content that is accurate, concise, and durable. Over-detailed encyclopedias become stale and ignored. Vague ones mislead. Your output will be the first document a new contributor reads.
79
</ROLE>

commands/encyclopedia-validate.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
---
2-
description: "Assemble and validate encyclopedia, write to output path (Phase 6)"
2+
description: "[DEPRECATED] Assemble and validate encyclopedia, write to output path (Phase 6)"
33
---
44

5+
> **DEPRECATED (v0.21.0):** This command is deprecated. Project knowledge now belongs in `AGENTS.md` files within the project repository. See the "Project Knowledge (AGENTS.md)" section in AGENTS.spellbook.md. This command will be removed in a future version.
6+
57
<ROLE>
68
Encyclopedia Curator. Your reputation depends on producing a clean, durable reference that stays accurate without constant maintenance.
79
</ROLE>

docs/commands/encyclopedia-build.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ flowchart TD
6565
## Command Content
6666

6767
``````````markdown
68+
> **DEPRECATED (v0.21.0):** This command is deprecated. Project knowledge now belongs in `AGENTS.md` files within the project repository. See the "Project Knowledge (AGENTS.md)" section in AGENTS.spellbook.md. This command will be removed in a future version.
69+
6870
<ROLE>
6971
Encyclopedia Architect. Your reputation depends on producing content that is accurate, concise, and durable. Over-detailed encyclopedias become stale and ignored. Vague ones mislead. Your output will be the first document a new contributor reads.
7072
</ROLE>

docs/commands/encyclopedia-validate.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ flowchart TD
6565
## Command Content
6666

6767
``````````markdown
68+
> **DEPRECATED (v0.21.0):** This command is deprecated. Project knowledge now belongs in `AGENTS.md` files within the project repository. See the "Project Knowledge (AGENTS.md)" section in AGENTS.spellbook.md. This command will be removed in a future version.
69+
6870
<ROLE>
6971
Encyclopedia Curator. Your reputation depends on producing a clean, durable reference that stays accurate without constant maintenance.
7072
</ROLE>

docs/commands/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Commands are slash commands that can be invoked with `/<command-name>` in Claude
3333
| [/deep-research-plan](deep-research-plan.md) | Phase 1 of deep-research: Thread decomposition, source strategy, and convergence... | spellbook |
3434
| [/design-assessment](design-assessment.md) | Generate assessment frameworks (dimensions, severity levels, verdicts, finding s... | spellbook |
3535
| [/distill-session](distill-session.md) | Distill oversized session: extract context, workflow, pending work into resumabl... | spellbook |
36-
| [/encyclopedia-build](encyclopedia-build.md) | Build encyclopedia content: glossary, architecture, decisions, and entry points ... | spellbook |
37-
| [/encyclopedia-validate](encyclopedia-validate.md) | Assemble and validate encyclopedia, write to output path (Phase 6) | spellbook |
36+
| [/encyclopedia-build](encyclopedia-build.md) | [DEPRECATED] Build encyclopedia content: glossary, architecture, decisions, and ... | spellbook |
37+
| [/encyclopedia-validate](encyclopedia-validate.md) | [DEPRECATED] Assemble and validate encyclopedia, write to output path (Phase 6) | spellbook |
3838
| [/execute-plan](execute-plan.md) | Execute implementation plans with structured review checkpoints. Use when you ha... | [superpowers](https://github.com/obra/superpowers) |
3939
| [/execute-work-packet](execute-work-packet.md) | Execute a single work packet: verify dependencies, run TDD task loop through thr... | spellbook |
4040
| [/execute-work-packets-seq](execute-work-packets-seq.md) | Execute all work packets in dependency order, one at a time, with context compac... | spellbook |

0 commit comments

Comments
 (0)