AGENTS.md¶
Guidance for AI coding agents (Claude Code, Copilot, Cursor) working in books.
A shelf of book projects, plus a small Python app that manages them and an editor to write them in. Content lives in library/<slug>/ as markdown and YAML and is the point of the repository; src/bookshelf/ is a read model over it that adds status, validation, manuscript compilation, a dashboard, a local editor and a Claude-backed assistant. "Done" for a prose change means the chapter is continuous with its neighbours and books validate reports nothing new. "Done" for a code change means tests pass and any new check is documented in docs/SCHEMA.md.
Stack & commands¶
Python 3.10+, standard library only at runtime except the optional ai extra (the Anthropic SDK). pytest for tests, ruff for lint. The studio is a stdlib HTTP server serving one hand-written page — no framework, no bundler, no build step.
# install dependencies:
pip install -e ".[dev]" # or just: export PYTHONPATH=src
# run the app:
books studio --open # the editor + AI assistant (needs the [ai] extra)
books list # also: show, new, add-chapter, stats, build, dashboard, serve, ask, context
# run tests:
python3 -m pytest
# lint:
ruff check src tests
# content checks:
books validate # schema + continuity across every book
python3 ../../tools/unwrap-prose.py --check
Conventions¶
- Conventional Commits:
type(scope): description(feat/fix/docs/refactor/test/chore/ci). Scope is the book slug for prose changes, the module for code. - Default branch is
main— branch from it and open a PR; never push to it directly. - README-First, README-Last: read the nearest
README.mdbefore changing a directory, and update it after. - Don't suppress type errors (
as any,@ts-ignore,# type: ignore) or leave empty exception handlers. - Markdown is one paragraph per line — no soft wrapping. CI enforces it.
Working here¶
- Prose: read the book's
outline.md, the act guide inguides/, and the adjacent chapters before writing. Names are decided innotes/characters.md; open questions live innotes/continuity.md. Never put(Chapter 8)or a[Placeholder]in narrative text — both are validation findings. - Code: no required runtime dependencies (the front matter parser has a stdlib fallback so
books validateworks in a bare checkout). The Anthropic SDK is the one exception and is optional --ai.pyimports it inside the client factory, and everything else must keep working without it. Onlycli.pyprints. A new check goes invalidate.pywith a code, a test, and a row indocs/SCHEMA.md. - Assistant:
ai.pybuilds every request from the book's own files. A new task is an entry inTASKS; changing what the model is given means changingbuild_brief/build_local, andbooks context <slug>shows the result without an API call. Model isclaude-opus-5-5with adaptive thinking -- don't addtemperature,top_porbudget_tokens, which that model rejects. - Full agent brief:
.github/copilot-instructions.md. Design rationale:docs/ARCHITECTURE.md. Editor and assistant:docs/STUDIO.md.
Fleet context¶
This repo is one of ~40 managed by the bamr87/bamr87 dash (registry: _data/projects.yml; tiered baseline: docs/STANDARDS.md). It is vendored there as a git submodule: commit and push changes here first — the hub only bumps its pointer afterwards. Shared CI, release, schema, and agent kits are seeded from the hub's templates/; prefer adopting those over hand-rolling equivalents.
This package lives in the zer0-CMS monorepo at packages/books/, and only the root .github/workflows/ runs: books.yml installs .[dev], then runs pytest -q and ruff check src tests on Python 3.10 and 3.12 (bin/zer0 run test books from the repository root does the same). The hub caller it replaced swallowed install failures, which is why the test suite adds src/ to sys.path in tests/conftest.py and the package has no required dependencies.
Still missing for the baseline: a LICENSE. This repo holds both code and original fiction, which usually want different terms, so it needs an owner decision rather than a default.