## Summary
Adds the `rust-style-guide` Agent Skill under
`.fabro/skills/rust-style-guide/` so Fabro workflow agent stages can
apply the project's Rust conventions when writing or reviewing Rust
code.
Skills are discovered by convention from
`{git_root}/.fabro/skills/*/SKILL.md` at agent-session startup — there's
no manifest wiring or per-workflow declaration. Once present, every
agent stage lists the skill in its system prompt and registers the
`use_skill` tool, so an agent can load it (or a node prompt can
reference `/rust-style-guide`). Committing it here (rather than relying
on a local `~/.fabro/skills` copy) is what makes it available to
**remote, clone-based runs** (Docker/Daytona), which only see committed
+ pushed files.
## Contents (44 files)
- `SKILL.md` — entry point (with a short note pointing the agent at the
in-repo location of the supporting files, since Fabro hands the agent
the `SKILL.md` body and it reads the rest itself)
- `guidelines.md` + `guidelines/` — 38 Rust style policy pages
- `workflows/` — 4 procedure pages (new project, library release,
performance investigation, code review/refactor)
## Source / attribution
Vendored from https://github.com/brynary/rust-style-guide (commit
`8fd2a4f`), trimmed to the runtime skill payload; the upstream repo's
mdBook site and authoring scaffolding are omitted. Note: the upstream
repo has **no LICENSE file** — flagging for a call on
attribution/licensing before merge.
## Notes
- No behavior/code change — this is skill content only; nothing is
compiled or bundled.
- No `{{user_input}}` placeholder was added; agents reference the skill
in prose or via `use_skill`. (If we later want deterministic
`/rust-style-guide <task>` slash expansion in node prompts, add the
placeholder to `SKILL.md` then.)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4.3 KiB
Library Errors vs Application Errors
Rule
Expose typed errors from reusable library boundaries, usually with thiserror; use anyhow inside applications and CLIs, and use miette only when rich user-facing diagnostics are worth the extra structure.
Why
Library callers need stable types they can inspect and branch on. Applications usually need fast propagation, useful context, and deliberate rendering at the final boundary.
Do
- Define a crate-local
Errorenum andResult<T>alias when a library crate has one cohesive error surface. - Use
thiserror::Errorfor ordinary typed errors. - Keep public error variants branch-oriented, not a dump of every dependency failure.
- Preserve causes with
#[source]or#[from]. - Keep useful structured fields on typed errors instead of folding them into
String. - Add
#[non_exhaustive]to public error enums that may grow in a published API. - Use
anyhow::Result<T>in binaries, command handlers, workers, tests, and internal application glue. - Add application context with
.context(...)or.with_context(...)instead of stringifying the source error. - Use
miettefor CLI diagnostics that benefit from labels, source snippets, help text, or polished reports. - Convert to
mietteonly at the presentation layer: std andthiserrorerrors do not cross?intomiette::ReportwithoutIntoDiagnostic::into_diagnostic()or#[derive(Diagnostic)], so keep internal errors onthiserrororanyhow. - Keep typed domain errors in application code when code branches on the failure.
Avoid
- Do not expose
anyhow::Errorfrom reusable library APIs. - Do not use
mietteas a general internal application error type. - Do not mix
anyhowandeyrein the same application without a project-level reason. - Do not make
Box<dyn std::error::Error>the default public error strategy. - Do not leak dependency error types from public APIs or stringify errors between layers; error taxonomy and error propagation own those rules.
- Do not create public variants only to mirror each dependency error.
Public API Notes
thiserror is usually fine for public libraries because it generates standard trait impls without becoming part of function signatures. Be more careful with the fields on public error variants: exposed source types can make dependencies part of the public contract.
For published crates, prefer stable domain variants and hide implementation details when callers should not depend on them. For internal application crates, optimize for clarity and accept breaking error-shape changes.
Example
Library crate:
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ConfigError {
#[error("configuration file {path} was not found")]
NotFound {
path: std::path::PathBuf,
#[source]
source: std::io::Error,
},
#[error("reading configuration file {path}")]
Read {
path: std::path::PathBuf,
#[source]
source: std::io::Error,
},
#[error("configuration value {key} is invalid")]
InvalidValue { key: String },
}
pub type Result<T> = std::result::Result<T, ConfigError>;
pub fn load_config(path: &std::path::Path) -> Result<Config> {
let contents = match std::fs::read_to_string(path) {
Ok(contents) => contents,
Err(source) if source.kind() == std::io::ErrorKind::NotFound => {
return Err(ConfigError::NotFound {
path: path.to_path_buf(),
source,
});
}
Err(source) => {
return Err(ConfigError::Read {
path: path.to_path_buf(),
source,
});
}
};
parse_config(&contents)
}
For the application-boundary side (anyhow context over a typed library error), see the example on error propagation, context, and messages.
Exceptions
- Use hand-written error impls when avoiding a dependency or tightly controlling a public API matters.
- Use
anyhowin internal libraries that are only application implementation details and are not consumed as reusable APIs. - Use
mietteat the CLI presentation layer when the diagnostic output is part of the product experience.