Skip to content

Coding agents

Tenchi gives coding agents deterministic inspection, previewable generation, structured diagnostics, and one complete validation command. An MCP-aware agent can access those operations directly through the Tenchi MCP server; an agent with filesystem and shell access can use the equivalent CLI workflow.

You remain in control because contracts, use cases, ports, and composition stay in ordinary Python files. The agent inspects evidence, edits those files directly, and runs the same checks you use locally and in CI.

Give an agent a Tenchi task

Generated applications include an AGENTS.md, so most agents will discover the local rules automatically. For an explicit first instruction, adapt this prompt:

Read AGENTS.md before editing. Run `uv run tenchi map` for the affected feature
and inspect its diagnostics and unresolved references. Explain the intended
files and relationships before changing them. Preview any generated structure
with `uv run tenchi make --dry-run`. Implement the change without hiding
explicit wiring, then run `uv run tenchi check`. If a contract changed, run the
OpenAPI compatibility diff before updating its snapshot. If an application
tool changed, run the tool compatibility diff before updating `tools.json`.
Finish with `uv run tenchi verify --base-ref <historical-ref> --json` and report
the receipt with the files changed.

If you already know the feature, include its name in the task so the agent can start with uv run tenchi map --feature <name> --json instead of loading the complete application graph.

What Tenchi provides

Design choiceWhat it gives an agent
Canonical application structurePredictable locations for contracts, behavior, ports, policies, adapters, and composition
AGENTS.md in every generated appRepository-local placement rules, dependency direction, and a validation loop
.mcp.json in every generated appProject-local registration for Tenchi's MCP tools and instructions resource
tenchi map --jsonA versioned graph with stable node IDs, source locations, registration state, and relationship evidence
tenchi task list --jsonValidated operational task names and their input/output JSON Schemas
tenchi make --dry-run --jsonA mutation preview with the files and follow-up wiring steps before anything is written
tenchi doctor --jsonStable diagnostic codes and source locations for architectural violations
tenchi tools --jsonRegistered machine-facing names, schemas, errors, and safety annotations
tenchi check --jsonOne bounded, complete result for formatting, linting, types, tests, architecture, and boundary snapshot drift
tenchi verify --base-ref <ref> --jsonOne completion receipt tied to an immutable commit, including checks, strict architecture evidence, and both compatibility reports
tenchi preflight --jsonRedacted, timeout-bounded evidence that the selected deployment environment is ready
OpenAPI compatibility commandsA historical contract baseline that an agent cannot accidentally replace and then compare to itself
Tool compatibility commandsDirectional proof that machine-facing input, output, errors, and safety did not break existing callers

Tenchi's documentation is also published as /llms.txt for compact navigation and /llms-full.txt for the complete guide.

1. Read the local rules

Start with the generated AGENTS.md. It describes the application's file layout, allowed dependency direction, explicit composition points, error and authorization conventions, and the commands that define done.

Tell the agent to follow those repository instructions ahead of generic framework advice; your application may add stricter local conventions.

2. Map before reading broadly

uv run tenchi map --json
uv run tenchi map --feature notes --json
uv run tenchi map --feature notes \
  --kind contract,route,use-case,policy,port,adapter --json

The complete map combines source declarations with composed API routes, operational tasks, background jobs, and application tools. A feature projection retains directly connected shared and cross-feature nodes, giving an agent a bounded starting context without hiding dependencies that cross the feature directory.

Inspect these fields before editing:

Node IDs, result keys, and diagnostic codes are stable within the declared schema_version. If your tooling parses the JSON directly, check that version before relying on the rest of the result. Tenchi snapshots the JSON Schema for every structured CLI result and MCP tool input and output in CI. Additive changes may retain the current version; breaking or unknown changes require a new version and preserve the older baseline.

3. Preview generated structure

uv run tenchi make feature notes --dry-run --json
uv run tenchi make use-case notes create_note --dry-run --json

Dry runs perform the same naming and conflict validation as a real generation without writing files. The result lists every planned path and the explicit wiring steps that remain app-owned.

After accepting the preview, run the command without --dry-run. Generators create files but do not rewrite route or infrastructure modules. The agent must make those composition changes in the application files, where you can review them.

4. Edit through the application boundaries

Follow the application architecture rather than placing code where it is merely convenient:

If the graph and the task disagree, inspect the source evidence and unresolved references before expanding the edit. tenchi map is an orientation tool, not a substitute for reading the definitions that will change.

5. Validate once, completely

uv run tenchi check --json

Check runs every step even after one fails, so you receive a complete repair list in one pass. Each step reports its command, exit code, duration, bounded standard output and error output, and whether either stream was truncated.

Treat ok: false as unfinished work. Do not stop after fixing only the first failed step, and do not silently weaken Ruff, Pyright, pytest, doctor, or the OpenAPI and application-tool snapshots to make the aggregate pass.

6. Compare boundary changes historically

For a contract change, compare before replacing the snapshot:

uv run tenchi openapi \
  --routes app.server.routes:api_routes \
  --title my_app \
  --diff openapi.json

uv run tenchi openapi \
  --routes app.server.routes:api_routes \
  --title my_app \
  --diff-ref origin/main \
  --snapshot openapi.json

Breaking and unknown changes fail closed. A baseline from the merge base, previous push, or previous release remains meaningful even when the branch also updates its committed snapshot. See OpenAPI and compatibility for the complete workflow.

For an application-tool change, use the parallel workflow:

uv run tenchi tools --diff tools.json
uv run tenchi tools \
  --diff-ref origin/main \
  --snapshot tools.json

This catches removed tools, narrower inputs, wider outputs, newly possible application errors, and less-safe annotations before an agent replaces the evidence. See Application tools for the complete compatibility rules.

Never replace the evidence first

Do not use --write before reviewing --diff. Comparing the generated document or manifest with the snapshot updated in the same change proves equality, not compatibility.

7. Produce the completion receipt

After reviewing and accepting any snapshot updates, verify the finished tree against the same historical point:

uv run tenchi verify --base-ref origin/main --json

The receipt contains the resolved commit, complete check result, application summary, diagnostics, unresolved relationships, and both compatibility reports. It passes only when every check passes, the map has no diagnostics or unresolved relationships, and neither boundary contains a breaking or unknown change.

verify does not replace the diff-before-write review. It proves that the finished tree—including accepted snapshot updates—still agrees with the historical contract. Use the pull request base, previous push, or previous release instead of the branch's current commit.

Choose the right command

CommandStructured result
tenchi map --jsonRoot, summary, nodes, edges, diagnostics, and unresolved references
tenchi make ... --jsonArtifact identity, dry-run state, files, next steps, and structured failure
tenchi doctor --jsonOverall status and source-anchored diagnostics with stable codes
tenchi check --jsonOverall status, counts, duration, and every validation step
tenchi verify --base-ref <ref> --jsonResolved baseline commit, checks, strict architecture evidence, and OpenAPI and tool compatibility
tenchi preflight --jsonDeployment-environment status, counts, durations, and stable failure codes without dependency details
tenchi routes --jsonA versioned result containing the app root and composed HTTP route table
tenchi tools --jsonA versioned result containing the app root and registered tool manifest
tenchi openapi --diff openapi.json --diff-format jsonA machine-readable API compatibility report
tenchi tools --diff tools.json --diff-format jsonA machine-readable tool compatibility report

Human and JSON modes represent the same operation. Use JSON when another tool will make a decision; use human output when a person is reviewing the work in a terminal.

Know when to inspect the source yourself

The application map is source-backed and conservative. Python permits dynamic imports, factories, decorators, and runtime mutation that static analysis may not be able to prove. Tenchi reports unresolved relationships rather than inventing certainty, and inferred edges remain visibly different from exact ones.

The map also does not prove business correctness. An agent still needs to read the relevant contract, use case, policy, port, and tests, then rely on the full validation loop.

Use MCP or the same CLI operations

Generated applications include .mcp.json for MCP-aware clients. Agents that only have shell access can follow the same workflow through the CLI and generated AGENTS.md; the result schemas and validation semantics stay the same.

Continue with the coding-agent MCP guide to connect a client, the CLI reference for every command option, or stability and releases for the compatibility guarantees around these result schemas.