Problem
When agents are spawned via npx plotlink-ows, they have no way to automatically discover the local API endpoints. The CLAUDE.md with API docs exists in the repo but not in the agent's working directory. Agents end up spelunking through npm cache source code to find route definitions.
Solution
On app startup, write/update a CLAUDE.md file in ~/.plotlink-ows/ with the API reference (auth, endpoints, workflows, valid genres/languages).
Why this works
- The app already owns
~/.plotlink-ows/ as its persistent config directory (lib/paths.ts)
- Stories live in
~/.plotlink-ows/stories/{name}/
- Claude Code walks up the directory tree looking for
CLAUDE.md files
- Any Claude session spawned in a story directory auto-discovers
~/.plotlink-ows/CLAUDE.md
Implementation
- In
lib/paths.ts (or app startup), write ~/.plotlink-ows/CLAUDE.md with the API docs from the repo's CLAUDE.md "Local Writer API" section
- Update the file on each startup so it stays in sync with the installed version
- Optionally add
GET /api/docs as a fallback for agents running outside the ~/.plotlink-ows/ tree
Acceptance Criteria
Problem
When agents are spawned via
npx plotlink-ows, they have no way to automatically discover the local API endpoints. The CLAUDE.md with API docs exists in the repo but not in the agent's working directory. Agents end up spelunking through npm cache source code to find route definitions.Solution
On app startup, write/update a
CLAUDE.mdfile in~/.plotlink-ows/with the API reference (auth, endpoints, workflows, valid genres/languages).Why this works
~/.plotlink-ows/as its persistent config directory (lib/paths.ts)~/.plotlink-ows/stories/{name}/CLAUDE.mdfiles~/.plotlink-ows/CLAUDE.mdImplementation
lib/paths.ts(or app startup), write~/.plotlink-ows/CLAUDE.mdwith the API docs from the repo's CLAUDE.md "Local Writer API" sectionGET /api/docsas a fallback for agents running outside the~/.plotlink-ows/treeAcceptance Criteria
~/.plotlink-ows/CLAUDE.mdis created/updated on app startup