# Coding agents

A coding agent that works on a program built on skillrc needs three facts: where the state is, which files a sync may write, and how to test without the user's agents. Put them in `AGENTS.md`:

```md [AGENTS.md]
## Sync

- skillrc runs the sync (`sync` from skillrc/sync). Our `SyncHost` is in `src/host.ts`; it reads
  the plan from `~/.config/mytool/mytool.json`.
- State is in `~/.local/state/mytool`: `state.json`, `last-run.json` and the store. Never edit them
  by hand; `loadState` and `saveState` do.
- Config edits go through `editConfigFile` or `setTomlTable`, never a whole-file write: the user and
  the agents edit the same files.
- Tests never touch the machine's agents. Every folder, HOME and git's config included, is a temp one.
```

## Testing without the user's agents

Build the `Places` in a temporary folder, and point every variable an agent or git reads there too. skillrc's own engine tests do this:

```ts
import { mkdtempSync, realpathSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { vi } from "vitest";

const root = realpathSync(mkdtempSync(join(tmpdir(), "mytool-")));
const home = join(root, "home");
vi.stubEnv("HOME", home);
vi.stubEnv("XDG_CONFIG_HOME", join(home, ".config"));
vi.stubEnv("CLAUDE_CONFIG_DIR", join(home, ".claude"));
vi.stubEnv("CODEX_HOME", join(home, ".codex"));
vi.stubEnv("GIT_CONFIG_NOSYSTEM", "1");

const places = Object.freeze({
  program: "mytool",
  state: join(root, "state"),
  config: join(root, "config"),
});
```

A `SyncHost` whose `targets` returns one folder under `home` stands in for an agent. A local source or a bare git repository in `root` stands in for a remote.

Two variables shorten waits in tests: `<PROGRAM>_LOCK_WAIT_MS` sets how long `withSyncLock` waits for a running sync, and `<PROGRAM>_SYNC_TIMEOUT_MS` sets the limit on a whole sync.

## Markdown copies

Every page on this site has a raw Markdown copy at `/raw/<page>.md`, such as `/raw/guide/sync.md`, and a full index at `/llms.txt`.

<!-- vitehub-docs:section-links -->
## In this section

- [Introduction](https://skillrc.loadsheet.dev/raw/guide.md)
- [Installation](https://skillrc.loadsheet.dev/raw/guide/installation.md)
- [Config files](https://skillrc.loadsheet.dev/raw/guide/config-files.md)
- [Fetching](https://skillrc.loadsheet.dev/raw/guide/fetching.md)
- [Definitions](https://skillrc.loadsheet.dev/raw/guide/definitions.md)
- [Sync](https://skillrc.loadsheet.dev/raw/guide/sync.md)
- [Coding agents](https://skillrc.loadsheet.dev/raw/guide/agents.md) (this page)

All pages: [llms.txt](https://skillrc.loadsheet.dev/llms.txt)

Something on this page does not work as written? Tell the user, and draft an issue for them to post: [issue tracker](https://github.com/words-with-agents/skillrc/issues). Report a security vulnerability privately, never in a public issue.
