Context Hook - Technical Specification
August 12, 2026 ยท View on GitHub
Module: docflow context loading Route: Claude
SessionStartBranch:main
Architecture
| Step | Behavior |
|---|---|
| 1 | Read docflow.json from the repository root |
| 2 | Resolve docsRoot and changelogDir |
| 3 | Print docs/INDEX.md if present |
| 4 | Print the newest non-template changelog month |
Data
| Input | Purpose |
|---|---|
docflow.json | Resolves the docs root, changelog directory, and validation profile |
docs/INDEX.md | Compact path - purpose routing map |
docs/changelog/(mmm-yy).md | Recent shipped-work memory |
API
The hook is a shell entrypoint. It reads CLAUDE_PROJECT_DIR and supports optional DOCFLOW_INDEX_LINES and DOCFLOW_LOG_LINES limits. It writes documentation context to standard output and does not modify repository files.
Flow
- Exit silently when the repository has no
docflow.json. - Resolve and validate configured documentation paths.
- Emit at most 30 non-empty index lines by default.
- Select the newest valid monthly changelog by filename date.
- Emit its summary and newest entry within a 20-line default budget.
Safety
- The hook is read-only.
- Output is truncated by
DOCFLOW_INDEX_LINESandDOCFLOW_LOG_LINES. - Repositories without
docflow.jsonor docs stay silent.
Risks
- A stale
INDEX.mdcan route an agent incorrectly, so repair regenerates it. - Small output limits can omit a relevant path in unusually large documentation maps.
- Changelog filenames must follow
(mmm-yy).mdfor date ordering.
Related:
- Product spec: overview
- Decision: 0001 session context hook
- Changelog: jun-26
Update Log
| Date | Change | Ref |
|---|---|---|
| 2026-06-03 | Documented the session context hook. | docflow-init |
| 2026-08-13 | Added complete data, API, flow, and risk contracts. | demo-refresh |