# Working with agents

Agents do their best work when they get a whole outcome, a way to run and inspect the product, and clear limits. This page covers how to set that up. It covers tasks, delegation, parallel work, the environment, architecture documents, and the knowledge agents read.

## Give agents outcomes

Describe the user's goal, the constraints, the behavior that must not change, the success condition, and the authority. Leave the implementation open when several approaches would satisfy those conditions. Give exact instructions only where an operation is fragile or an invariant is protected.

An agent should work through routine failures it can diagnose and fix within scope. It should stop and report when it reaches a real decision, missing authority, or a prerequisite it cannot get. The report includes the evidence needed to decide.

## One record per task

Before starting, search for related open work. A duplicate report joins the existing investigation, but each customer keeps their own communication thread.

Keep one work record for each consequential task. Track lifecycle state and condition separately. For example, a change can be deployed and blocked. Close only when the declared exit has evidence and every follow-up has an owner. Cancelled work records the reason, what remains, the cleanup, and who revisits it.

If a reported problem cannot be reproduced, record the conditions you tried and the next observation that could help. Never mark the report invalid for that reason alone.

## Delegate bounded units

Delegation hands over an assignment. It does not hand over accountability or the delegator's permissions. A delegation brief names:

- the goal and the inputs,
- what the worker may change, and what it must leave alone,
- its authority and dependencies,
- the expected output and the evidence for it,
- the stop condition.

Workers report artifacts, checks, limits, and open issues. The delegating owner reads the actual output. A worker's "done" is a claim. Agreement among several agents is not evidence either.

Use a script, not an agent, for narrow mechanical work. Add agents only when the work splits into parts that do not share outputs, or when an independent check is required.

Before replacing a stalled worker, inspect what it produced and changed, and stop it so two workers do not compete. The replacement gets the original brief, every correction since, and the verified current state.

## Isolate parallel work

A separate checkout isolates files and nothing else. Parallel tasks also need their own databases, ports, browser profiles, queues, credentials, and paid test resources.

- Agree shared contracts, such as an API shape, before parallel work starts.
- Give one writer each shared artifact that cannot be merged automatically.
- Give each parallel task its starting revision, its scope, its output, and its checks.
- Combine results in dependency order, then test the combined result. A finished subtask does not prove the whole works.
- If a service cannot be isolated, let one task use it at a time and record which task holds it.
- If two tasks collide, stop writing, keep both outputs, and name one owner to integrate them.

## Make the product runnable

An agent must be able to set up the product, start it, reach a realistic state, use it the way a user would, see failures, identify which version is running, and reset. Each of those needs a documented command or tool.

- **Readiness** means the environment can perform the task's real operation. A listening port is not readiness. Check configuration, dependencies, sign-in, permissions, and data.
- **Setup** converges when rerun. It never disables authentication, deletes unrelated state, or changes business logic to make startup pass. If a prerequisite fails, report it.
- **Development shortcuts**, such as a test login route, never reach production. Real authentication keeps its own checks.
- **Test data** is synthetic or approved and sanitized. A copy of the production database is not test data, even outside production. It still holds real people's data.
- **Snapshots** of an environment hold tools and seed data. They never hold login sessions, production credentials, or another task's identity.
- **Tools** return the real result, the exit status, where to find logs, and which resource they touched. An accepted background job is not finished work. Return its ID and how to check it.
- **Shared machines.** Find the owner of a process, database, or port before stopping it.

When people keep rescuing agents from the same problem, fix the tool or the setup. A longer prompt does not fix a broken environment.

## Keep knowledge where agents find it

- Keep a short entry file at the root of each repository, such as `AGENTS.md`. It covers the purpose, where the architecture is described, the invariants, the tools, and the verification commands.
- Put guidance for a subsystem next to that subsystem.
- Put task procedures in playbooks or skills, each with a clear "when to use".
- Give each rule one authoritative home. Link to it instead of copying it.
- Update the guidance in the same change that alters behavior, tools, authority, or ownership.
- Keep standing guidance apart from task state and credentials.
- Delete advice that a tool, a type, or a check now enforces.

Knowledge comes in distinct kinds. Explanations say why. Reference lists facts. Playbooks give generic task steps. Runbooks give product-specific commands for one operation, with its starting state, stop conditions, and expected results. Keep them apart.

To check that guidance works, run a [fresh-agent trial](https://handbook.askre.page/evidence.md#fresh-agent-trials).

## Check architecture documents against the code

Architecture documents describe intent. When they disagree with the code, record what the code does and fix the document.

Keep a map that an agent can check: components, a typical request path, data stores, background work, external effects, trust boundaries, the source of truth for each fact, and the places where old and new versions run together.

For each boundary, record who owns it, its inputs and outputs, its authentication, how it fails, and how to diagnose it. Before changing a shared contract, find its callers, including old clients, jobs, and admin paths. Removing a field, a queue, or an integration needs evidence that nothing still uses it.
