Bake Agent Context
Bake tasks for discovering and installing context files shipped by Cargo dependencies. It is the Rust counterpart to the Ruby agent-context gem.
Setup
Add the task library to the unpublished bake/ crate in your project, then link it once from that crate's main.rs:
[]
= "0.17"
= "0.1"
use bake_agent_context as _;
Install context and skills from all resolved dependencies and update agents.md:
Other tasks:
Generated context and skill files are written to .agents/context/ and .agents/skills/; ignore those directories in Git. Other files directly under .agents/ may contain project-owned instructions. The generated agents.md is intended to be committed.
Context documents marked with type: skill are installed only under .agents/skills/, along with their companion resources. Their installed names are prefixed with the provider crate name, and they are omitted from .agents/context/ and the generated agents.md index. Use agent:context:install --package CRATE to install both context and skills from one provider. The separate skill tasks are useful for listing skills or installing a selected skill.
Provide context from a crate
Add a top-level context/ directory to the crate and ensure Cargo packages it. When using an explicit include list in Cargo.toml, include context/**:
my-crate/
├── Cargo.toml
├── context/
│ └── getting-started.md
└── src/
Bake Agent Context uses the crate description from Cargo.toml and extracts each Markdown file's title and first sentence for the generated agents.md section. Ordinary context files need no Markdown front matter. A context document can opt into skill installation with YAML front matter; see Using and Providing Context.
Context
This crate includes guides for its users and for other crate authors:
- Getting Started explains how to add and run the Bake tasks.
- Using and Providing Context describes dependency context and how to publish context from a crate.
- Agent Context explains how to organize package guidance and repository-only instructions.
- Agent Context Specification defines the language-agnostic context directory and installation conventions.
- Rust Context provides shared development guidance for Socketry's Rust crates.
Releasing
Prepare a release with cargo bake cargo:version:patch (or minor, major,
or bump --version X.Y.Z), then run cargo bake cargo:release and open a
pull request. After review and merge, GitHub Actions publishes the release
when the configured crates-io environment approves it. See the
Cargo publishing guide.
Contributing
Please open an issue or pull request on GitHub.
Agent Context
Before contributing, read agents.md and the relevant context files it links. If agents.md is missing or out of date, run cargo bake agent:context:install to install context from dependencies and update the index.