> ## Documentation Index
> Fetch the complete documentation index at: https://docs.insforge.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent-Native Initiatives

> Explore the primitives — CLI harness, config as code, branching, and diagnostics — that let a coding agent operate your InsForge backend without a dashboard.

Most backends assume a human in a dashboard. InsForge assumes a coding agent at a terminal. The products (Database, Auth, Storage, and the rest) are the building blocks; the primitives on this page are how an agent operates them: as files it can edit, branches it can test on, and a backend it can diagnose and fix on its own.

> [!NOTE]
>
> New here? Start with [Connect via CLI](https://docs.insforge.dev/quickstart.md) to link your project. This section is about how an agent *works* with the backend once it is connected.

## The primitives

> [card] [CLI harness](https://docs.insforge.dev/agent-native/cli-harness.md)
>
> The agent's hands. One terminal interface for login, schema, deploys, config, and diagnostics.

> [card] [Diagnostics & advisor](https://docs.insforge.dev/agent-native/diagnostics.md)
>
> Pull advisor findings, DB health, metrics, and error logs the agent can read and fix.

> [card] [Config as code](https://docs.insforge.dev/agent-native/config-as-code.md)
>
> Auth, SMTP, storage, retention, and deployment settings live in `insforge.toml`. Plan and apply like infrastructure.

> [card] [Branching](https://docs.insforge.dev/agent-native/branching.md)
>
> Clone the whole backend into an isolated branch to test risky changes, then merge or reset.

## Why it matters

A person and an agent want different things from a backend. A person wants a UI to click. An agent wants a stable text interface it can drive, read back, and reason about. That shows up everywhere in InsForge.

Schema changes are [migrations](https://docs.insforge.dev/core-concepts/database/migrations.md) in your repo, and project config is an [`insforge.toml`](https://docs.insforge.dev/agent-native/config-as-code) file, so the agent edits text, commits it, and reviews it in a PR instead of clicking through forms. When it wants to try something risky, it spins up a [backend branch](https://docs.insforge.dev/agent-native/branching.md), runs the change against a copy, and throws the branch away if it goes wrong. When something looks off, it fetches [diagnostics and advisor findings](https://docs.insforge.dev/agent-native/diagnostics.md) directly with `npx @insforge/cli diagnose`, no dashboard in the loop, and applies the fix itself. That last part is also how the backend gets more secure: the agent reads a security finding like a permissive RLS policy and remediates it on its own, instead of waiting for a human to remember to check. And it reads current schemas, logs, and metadata straight from the backend with `npx @insforge/cli metadata`, so it works from real state rather than guessing.

## The loop

These chain together. A session usually goes:

1. Read the current state with `npx @insforge/cli metadata`.
2. Branch the backend, write a [migration](https://docs.insforge.dev/core-concepts/database/migrations.md) and check what is pending with `npx @insforge/cli db migrations list`, or edit `insforge.toml` and preview the config diff with `npx @insforge/cli config plan`.
3. Apply it with `npx @insforge/cli db migrations up --all` or `config apply`, against the branch first, then the parent.
4. Run `npx @insforge/cli diagnose` to check advisor findings and error logs, and ask `diagnose --ai` to interpret them.
5. Apply the remediation, re-run diagnose, and merge the branch.

## Next steps

* Read the [CLI harness](https://docs.insforge.dev/agent-native/cli-harness.md) to see the full command surface an agent drives.
* Set up [config as code](https://docs.insforge.dev/agent-native/config-as-code.md) so project settings live in version control.
* Use [diagnostics](https://docs.insforge.dev/agent-native/diagnostics.md) to let the agent find and fix backend issues.
