Own Your AI Agent's Context in the Repo
Cold open
An agent can finish a session with a clean diff and still leave the next session guessing. The files remain; the explanation of why they were changed may not.
If the same architecture, conventions, and project boundaries need to be rediscovered every time, your repository is missing a useful handoff layer. The practical fix is to keep durable project guidance in versioned files and keep one-task instructions in the prompt for that task.
Separate project context from task context
A coding conversation is good at carrying the current request: which issue is in scope, what the user wants, and which files to change today. It is a poor long-term source for facts the next contributor also needs. A chat can be unavailable to another teammate, excluded from a new session, or simply too large to reread.
Project context is different. It explains the codebase in terms a new session can use: how to run it, where an existing feature lives, which boundary must remain intact, and how to verify a change. Put that guidance in files that travel with the repository. Use the task prompt to say what to do now, what is out of scope, and what result to return.
That division helps people too. A developer who has not seen the previous conversation can clone the project, inspect the same guidance, and understand the intended shape of a change. The repository becomes the shared reference; the conversation becomes a temporary work order.
12 production screens. Login and database wired.
The SaaS Dashboard Kit includes login, a database, and a working dashboard. Live demo at saas.otf-kit.dev.
Write down decisions that are expensive to rediscover
A useful project instruction file is not a second README or a transcript of every design discussion. It is a short index to decisions that affect future work. Include:
- The stack and the important application entry points.
- The boundary between packages, services, or generated files.
- The commands for local setup and focused verification.
- Conventions that are not obvious from the neighboring code.
- Invariants: what must not be changed, and where the source of truth lives.
- Links to deeper documentation for details that do not belong in the quick-start layer.
Prefer a pointer to the actual route or schema over a copied explanation that will go stale. If your instructions say “all billing changes go through the subscription service,” link to that service and explain the invariant. Do not paste credentials, customer data, or temporary access tokens into project guidance. Durable does not mean safe to share.
Keep the instructions concrete and bounded
A short example is easier to follow than broad advice such as “use best practices.” Tell the agent what to inspect and how to check its work. For example:
# Project guide
- Read `docs/architecture.md` before changing service boundaries.
- API routes live in `server/routes/`; database definitions live in `server/db/`.
- Use the existing query layer. Do not add raw SQL to a route.
- After a TypeScript change, run the repository's documented type-check command.
- If a generated file needs to change, update its source and regenerate it.The file should describe the current repository, not a future architecture you hope to build. If a rule changes, update the code or the documentation that proves it, then remove the obsolete instruction. A set of old rules is worse than no rules because the agent can follow them confidently and still be wrong.
Put guidance where each tool actually reads it
There is no universal instruction filename that every coding tool loads the same way. OpenCode uses AGENTS.md; its documentation says it uses project CLAUDE.md only when no AGENTS.md exists. Claude Code uses CLAUDE.md files for project instructions and can also read AGENTS.md when configured. Cursor supports root AGENTS.md and version-controlled .cursor/rules; its docs describe .cursorrules as legacy and recommend migrating. Check the specific tool's current docs, version, settings, and working directory before assuming a file is loaded.
Treat those as different loading mechanisms, not as interchangeable magic names. Keep the canonical project facts in ordinary docs or a concise shared guide, then add small tool-specific entry points where a tool needs them. Link those entry points to the canonical material. If you maintain a compatibility file for an older tool setup, say what it mirrors and who owns keeping it aligned.
The same distinction applies to global and project rules. A personal preference can belong in a user's global configuration. A team convention that must travel with a checkout belongs in the repository. Do not put an individual developer's machine path or local sandbox URL into a team-wide file unless everyone can use it. OTF's OpenCode example reports: “On 13 October 2026, the kit's own type-check passes in a fresh install. Our test change added no type errors.” Treat that dated sentence as the scope of the check, not proof that the generated page ran in an app or that the kit's broader tests passed.
Make each task prompt narrow
Project rules explain how to work in this codebase. A task prompt explains the change. Give it a concrete goal, constraints, and evidence to return. For example:
Add a project export endpoint.
Before editing, read the route and schema references in the project guide.
Reuse the current authorization and query patterns. Do not change the export format.
Run the documented focused checks and summarize the files changed.Keep repeatable recipes in versioned prompt files only when the task recurs and the recipe has been reviewed against the real code. A reusable prompt should point to the project rules, not repeat them in a second copy. That gives the agent the relevant constraints without turning every prompt into a policy dump.
Test the handoff with a fresh session
The file existing is not proof that the agent loaded it. Start a new session from the repository root and ask the tool to identify the project instructions it found. Then give it a small, reversible task that exercises one important convention. Check whether it reads the referenced source, stays inside the intended boundary, and uses the documented verification command.
If the session misses a rule, first check the tool's documented discovery behavior and the file's location. A rule inside a nested package may apply only when the agent is working in that path. A Cursor rule may be scoped by a glob or require manual inclusion. A long root file may also bury the one instruction that mattered. Fix the loading path or simplify the guide; adding more repeated prose is rarely the first fix.
Review the result like any other contribution. Instructions can reduce repeated orientation, but they do not replace code review, tests, or a human decision about a risky change. Keep the file under version control so edits to the handoff are reviewable alongside the code they describe.
What an owned starter repo can give you
A starter repository can make this practice easier by putting its architecture, conventions, and task examples beside the application from the beginning. As of 15 October 2026, OTF's delivered kits are SaaS Dashboard, Fitness, and Arcade. Their current agent materials include AGENTS.md, CLAUDE.md, .cursorrules, and between 22 and 27 task prompts, depending on the kit. Check the specific kit documentation for its actual files and workflows; the prompt set is not a guarantee that a custom integration or feature is already implemented.
For example, the SaaS Dashboard documentation describes its Vite, React, Hono, and Postgres layout and links to the kit's conventions and prompt examples. Treat it as an optional codebase to inspect if that stack fits your project. The kit does not make an unrelated agent integration for you, and its files still need to be reviewed and adapted to your own product. For an example of configuring tool-specific guidance, see OTF's Expo skills handoff; it is a separate article, not evidence that every kit contains an Expo setup.
Keep the repo as the handoff
The next session should not need to reconstruct a decision from a closed chat. Put stable architecture and conventions in versioned project guidance, keep task prompts focused, and link every important rule to the source that can prove it. Then verify that your chosen tool actually loads those files from the directory where you work.
If you want to start from an editable repository that already includes app structure and agent-facing materials, explore the SaaS Dashboard kit. Or start here to choose a template that fits your project.
Sources
- OpenCode Rules documentation — checked 15 October 2026.
- Anthropic: Manage Claude’s memory — checked 15 October 2026.
- Cursor Rules documentation — checked 15 October 2026.
- OTF SaaS Dashboard documentation — checked 15 October 2026.
- OTF kit catalog — checked 15 October 2026.
- OTF OpenCode example — dated 13 October 2026; checked 15 October 2026.
- OTF Expo skills handoff — checked 15 October 2026.
Ship the product, not the setup.
- 12 production screens — auth, team, analytics, and settings
- Login and a real database are wired in
- AI configs pre-tuned so your agent extends instead of regenerates
Ship your first screen tonight — free starter in your inbox
The quickstart, the SDK repo and the live kit demos, on this screen and in your inbox.
No spam. Unsubscribe any time.