tarek.kharsa

home / lessons / t3 code · lesson 8

AI-native engineeringT3 Code · lesson 8 of 81 min read

Write docs for your most frequent contributor

In this repo, the most frequent contributor is an AI agent running inside the app itself.

Problem

The agent changing this repo usually runs inside the product it's changing, next to real data and other agents. One pkill, one write to the wrong database or one baked-in URL can break the developer's machine.

Idea

Write the agent guide as the system's real failure modes, each with the mechanism and the safe alternative, and make data flow one way into sandboxes.

Most … contributions will come from [the app] itself, often controlled remotely.

That sentence changes everything. The agent editing this repo is usually running inside the product it's changing, on a developer's machine, next to their real data and other agents. So the agent guide isn't a style guide. It's a list of the system's real failure modes, each with the mechanism behind it and a safe alternative.

Try it: stop your stuck dev server

three ways to kill a process, on a machine shared with other agents

pkill -f matches the full command line. Your own agent's command line contains the worktree path, so killing by that pattern kills you. Killing by a tool name hits other agents' servers. The safe way: find the process listening on your port and confirm its working directory is your worktree.

The three ways to hurt yourself

  1. Killing by patternNever pkill -f, pgrep | kill, or kill a PID you found by matching a name, path or worktree string. "Your own agent process has this worktree's path in its argv, and this machine runs several other dev servers at once." Kill only a PID you captured at spawn, or the owner of your port from ss -H -ltnp after confirming /proc/<pid>/cwd is your worktree.
  2. Writing to the live installThe developer's real database is in use while you work. Reading and copying from it are fine; starting a server against it, opening it read-write, or "cleaning it up" is not.
  3. Baking in originsSetting VITE_HTTP_URL or VITE_WS_URL for dev bakes localhost into the bundle and "silently breaks every remote browser." Dev is single-origin; Vite proxies /api, /ws, /oauth and /.well-known.

Data flows one way

"An empty database is a bad test", so the guide tells agents to seed their worktree from real data, through a script that keeps the safety properties:

What it does

Rebuilds the worktree's database from a read-only snapshot of the real one, keeping recent projects and their stopped threads.

What it drops

Scheduled tasks, pending work and auth sessions, "so your dev server never runs the developer's agents."

Copy in, never symlink. Data flows one way: into your sandbox, never back out.

Verification has a budget

  • Smallest proof that the change works: the tests you touched, targeted lint and typecheck for your scope. CI owns the full suite.
  • Bot findings get verified against the source. Fix real ones, dismiss false positives with a written reason, and stop when the bots are green on the latest commit.
  • A missing mobile client is a build step, not a blocker: a script checks the native fingerprint and builds only when needed.

And an escape hatch

Do not preserve complexity just because it already exists. Do not introduce machinery because it looks architecturally impressive. Understand the real constraint, then fight for the smallest model that makes the correct behavior unsurprising.

When a rule fights the task, the agent says so and gets a human sign-off before breaking it. Rules with a stated mechanism are easy to apply to new cases; rules without one get misapplied.

Steal this

Write your agent guide as a list of your system's real failure modes: the mechanism, the safe alternative, and the command to use instead. Make data flow one way into sandboxes, and give verification a budget.

Use it in your code

A prompt for your coding agent

Run it from the root of your repo. It checks whether the idea fits before it changes anything.

Write the "ways to hurt yourself" section of this repository's agent guide (AGENTS.md, CLAUDE.md or similar).

The idea: an agent working here runs on a real developer machine, often next to real data, other agents and the developer's own running app. The useful guide isn't a style guide; it's the system's real failure modes, each with the mechanism behind it and the safe command to use instead.

1. Explore how this project runs locally: dev servers, ports, background processes, databases and data directories, caches, environment variables that get baked into builds, and anything that talks to production or a shared service.
2. List the concrete ways an agent could cause damage here. Typical ones: killing processes by name or pattern (the agent's own command line often contains the worktree path), writing to a real or shared database, deleting caches or data directories, baking local URLs or secrets into a bundle, pushing to a shared branch.
3. For each, write three lines: the rule, the mechanism (why it breaks), and the safe alternative with the exact command, for example "kill only the PID you started, or the owner of your port after checking its working directory".
4. If the project needs realistic test data, design a one-way seeding step: copy a read-only snapshot into the agent's sandbox, drop anything that could trigger real side effects (scheduled jobs, pending work, credentials), and never symlink back.

Keep it short and concrete, and show me the draft before writing the file.

Read the source

Where this comes from

T3 Code (pingdotgg/t3code), the open-source GUI for coding agents. The files behind this lesson: