Imported from VDuchauffour/rust-template (
AGENTS.md). Install upstream withnpx skills add VDuchauffour/rust-template. Copyright stays with the author.
AGENTS.md
Guidance for OpenCode sessions working in this repository.
What this repo is
A Copier template for scaffolding Rust projects. It is not itself a Rust
application — there is no Cargo.toml or src/ at the root. Do not run
cargo build, cargo test, or cargo clippy at the repo root; they will fail.
All renderable project files live under template/ as Jinja templates
(suffix .jinja). The template is defined by copier.yml at the root, which
sets _subdirectory: template.
Two-tier layout — do not conflate
| Location | Purpose |
|---|---|
.github/workflows/ (root) |
CI for this template repo (PR title checks, template linting) |
template/.github/workflows/ |
CI that ships to generated projects (cargo fmt/clippy/test, coverage, publish) |
.gitignore (root) |
Ignores for the template repo itself |
template/.gitignore |
Ignores that ship to generated projects |
The same split applies to .pre-commit-config.yaml, .yamlfix.toml,
.vscode/, .devcontainer/ — all live in template/ and are rendered into
generated projects, not used by the template repo itself.
Testing template changes locally
# Render the template into a temp dir. All three flags are mandatory:
# --with jinja2-time → copier.yml uses jinja2_time.TimeExtension
# --vcs-ref=HEAD → test the working tree, not the latest git tag
# --trust → _tasks run shell commands (rm -f ...)
uvx --with jinja2-time copier copy . /tmp/render \
--defaults --vcs-ref=HEAD --trust
# Then verify the rendered project compiles:
cd /tmp/render && cargo check && cargo +nightly fmt --check && cargo clippy -- -D warnings
To test a specific variant (e.g. no license, or with crates.io publish):
uvx --with jinja2-time copier copy . /tmp/render \
--defaults --vcs-ref=HEAD --trust \
--data license=None --data copyright_holder= \
--data publish_to_crate=true --data build_binaries=true
Copier _tasks (post-render conditional deletion)
copier.yml defines three tasks that run after rendering:
publish_to_crate=false→ removes.github/workflows/publish.ymlbuild_binaries=false→ removes.github/workflows/build-binaries.ymllicense=='None'→ removesLICENSE
These are shell commands, which is why --trust is required when copying.
Toolchain quirks
- rustfmt requires nightly:
cargo +nightly fmt. Therustfmt.tomlsetsgroup_imports = "StdExternalCrate", which is a nightly-only option. The CI andjustfileboth pin+nightlyfor formatting. - pre-commit requires
uv:just pre-commit-installrunsuvx pre-commit install.uvmust be on PATH. - No
Cargo.lockcommitted — gitignored (library convention) at both root and template levels.
just recipes (in template/justfile)
Available in rendered projects (or in the template repo if you copy a
justfile out). Key shortcuts:
| Command | What it does |
|---|---|
just ci |
fmt-check + lint-strict + test |
just fmt |
cargo +nightly fmt |
just lint-strict |
cargo clippy -- -D warnings |
just machete |
Detects unused dependencies (installs cargo-machete if missing) |
just udeps |
Detects unused dependencies via compiler data (nightly, installs cargo-udeps if missing) |
PR conventions
Enforced by .github/workflows/pr-enhancement.yml at the repo root:
- PR titles must follow conventional commits (e.g.
feat:,fix:,chore:). - Subject line must not start with an uppercase letter.
- PRs labeled
dependenciesbypass title validation (for Renovate).