I keep two goals in mind: 1) codify how we work into the repo so the agent reads the room, and 2) build a tight feedback loop so the tool improves with us.
1) Start safe, then earn trust
Plan first, approve tiny diffs. In Codex, begin in Read Only and only move up the approval ladder when the plan makes sense. Full access is for sandboxes and short-lived branches.
What I do
- Create
feat/<short-desc>. - Ask for a plan and the smallest testable change.
- Review the diff. If it’s more than 3 files, split it.
- Repeat until the task is done.
2) Put rules in the repo so the agent “gets” your context
Claude Code: keep a short CLAUDE.md at the repo root with code style, safety rules, and how to work here. You can download a starter file here: CLAUDE.md.
Opencode: add an AGENTS.md. This is first-class in their docs: run /init, commit the file, and define a primary agent plus laser-focused subagents with minimal tool access. You can download a starter file here: AGENTS.md.
Aider: check in .aider.conf.yml and stop passing flags. Pin models, file globs, and behavior. You can download a starter file here: aider.conf.yml.
Minimum viable content for rules
- Code and testing style you actually follow.
- Tech constraints that matter.
- Safety: no secrets in logs, no direct writes to main.
- Workflow: plan, tiny diffs, PR every time.
3) Limit the agent’s world
Small scope = predictable changes.
- In Aider, set
files:globs in.aider.conf.yml. - In Opencode, restrict tools per agent in
AGENTS.md. - In Gemini, whitelist MCP tools explicitly (include/exclude).
4) Wire useful MCP servers (one at a time)
If a tool needs external context, use MCP and start with a single, read-only server.
Good defaults:
- Context7 for up-to-date, version-specific docs and code snippets. Great for avoiding stale API usage.
- GitHub MCP Server for repo issues/PRs when you want traceability.
Gemini CLI plays nicely here and has guides for MCP configuration. Test the same prompt in CI in a non-interactive run.
5) Get local models right (or don’t use them yet)
Local models are great for privacy and latency but can silently truncate context. With Ollama, some models start at 4k context unless configured. That breaks agentic workflows.
Rules of thumb
- Prefer coding-tuned models.
- Verify the actual context window your runtime uses.
- Keep diffs small so they fit the window.
6) Treat git as the source of truth, not the chat
Keep commits surgical, messages factual, and tie every change to a test.
Commit message skeleton
feat: add paginated /reports endpoint
- Adds GET /reports?page=…&size=…
- Validates input, returns total count
- Tests: happy path, invalid page, max size cap
7) Close every session with a feedback loop
Don’t just end the chat. Ask the agent what it learned and how it would improve its own system prompt. Then incorporate useful bits into CLAUDE.md, AGENTS.md, or .aider.conf.yml.
Prompt I reuse
- “From this session, what did you learn about this repo, our patterns, and our constraints?”
- “Rewrite the system prompt for this project with those insights. Keep it under 200 words.”
- “List three concrete guardrails we should add to prevent mistakes next time.”
This turns ad‑hoc chats into a growing project brain.
8) Quick recipes by tool
Codex
- Start with
/approvals read-only, ask for a plan, then permit one tiny change. Keep network access off unless needed.
Gemini CLI
- Configure one MCP server (Context7 or GitHub MCP). Run the same prompt non-interactively in CI to lint commit messages.
Claude Code
- Use
/initto seedCLAUDE.md. Let it propose edits, then you approve staged diffs and commit. Add a subagent if a domain needs special rules.
Aider
- Check in
.aider.conf.ymlwith model and file globs. If local, verify Ollama context and the model’s tool-use capabilities.
Opencode
- Create
AGENTS.md, define a primary agent and adb-migratorsubagent with the smallest tool set possible. Commit both rules and config.
Snippets you can drop in today
CLAUDE.md (starter)
# Project rules
## Code style
- Prefer small, pure functions. Tests first for changed behavior.
## Tech constraints
- Backend: FastAPI + PostgreSQL (async endpoints).
- Frontend: React + TypeScript. State via Zustand.
## Safety
- No secrets in logs. No direct writes to main.
- Plan first for non-trivial changes, then small diffs.
## Workflow
- Branch: feat/<short-desc>
- Review diffs, insist on tests
AGENTS.md (Opencode)
# Agents for this project
## Primary
description: "General coding agent"
system: |
Make small, focused changes with tests.
Follow service boundaries from README.md.
tools: [filesystem, terminal, git]
## db-migrator
description: "Owns DB schema changes and migrations"
system: |
Generate safe Alembic migrations and idempotent scripts.
Require approval before applying migrations.
tools: [terminal, filesystem, git]
.aider.conf.yml
model: ollama/qwen2.5-coder:7b
git: true
watch: true
files:
- src/**
- tests/**
# Point to OpenAI-compatible endpoint when using Ollama:
openai-api-base: http://127.0.0.1:11434/v1