Agent context
What a coding agent reads before it writes firmware: the AGENTS.md from espx new, and espx context.
An agent writing esp-hal code needs facts it cannot guess: which chip, which pins drive the LED, and which esp-hal release the project uses, since the API changes between releases. espx collects them in one text. espx new writes it to the project's AGENTS.md, and espx context prints it on demand with what is attached right now.
AGENTS.md
Every project espx new creates has an AGENTS.md, the file coding agents read before they write code. For a project made with espx new blinky --board xiao-esp32c6, before the first build, it reads like this:
The versions depend on the esp-generate template of the day. The sections are always the same:
| Section | Contents |
|---|---|
| The espx loop | The build, flash, monitor, fix loop, with each MCP tool and the matching CLI command |
| Target | Chip id and name, Rust target and toolchain channel; the board model and its pins when one is recorded; the bound board from espx.toml; the esp-hal version and features; the other esp-rs crates; defmt logging when the project uses it; the release binary once built |
| Examples | The link to the esp-hal examples at the exact release, or a note to build first |
Without a recorded board, the Target section says so and tells the agent to check pins against the board's documentation before driving a GPIO.
AGENTS.md is written once, when the project is created. Run espx context for the current facts.
espx context
context prints the same markdown for the project in the current directory (or --dir), with an Attached section at the end listing the serial ports with a dev board on them. After a build it carries the exact esp-hal version from Cargo.lock and the examples link. --board names the board model when the project records none. --json prints the gathered facts as one document; see JSON events.
espx finds the board model from --board, else from the Board: line in AGENTS.md or README.md, which espx new --board writes.
The same text is available to agents three more ways:
- The
contextMCP tool, which also lists the open monitor sessions. - The
espx://project/contextMCP resource, for the projectespx mcpwas started in. - Copy agent context on a project's Details tab in the desktop app.
The examples link
espx does not download the esp-hal examples. It links to them on GitHub at the tag of the exact release Cargo.lock resolves:
The link appears only when Cargo.lock pins exactly one esp-hal version from crates.io. Before the first build there is no lockfile, so the text says to build first. A git or path dependency on esp-hal, or two esp-hal versions in one lockfile, has no release tag to link to, so there is no link either.
Agents should take API usage from those examples, keeping to the ones that support the chip, and take pins from the context or the board_catalog tool, never from memory. The MCP server's port-example prompt asks an agent to do exactly that for one example.