rust-hexagonal

rust-hexagonal is a skill for Claude Code from pedromneto97/custom-skills. It costs 71 tokens per session (2,447 once invoked), scanned A, original, MIT.

A way to structure Rust backend software using ports and adapters. It keeps business rules separate from outside systems such as HTTP, databases, APIs, caches, email, and command-line tools.

In plain words
What is it for?
Use it when building or organizing Rust backends, defining interfaces as traits, adding HTTP, gRPC, database, or other adapters, and wiring their dependencies.
Why use it?
It makes the core business logic less dependent on infrastructure, so external technologies can be changed without moving that logic into the domain code.

Skill for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/pedromneto97/custom-skills/rust-hexagonal
Any agent
npx skills add pedromneto97/custom-skills --skill rust-hexagonal
Clone the repo
git clone --depth 1 https://github.com/pedromneto97/custom-skills

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rust-hexagonal

README.md
[![agentmods](https://agentmods.dev/badge/skills/pedromneto97/custom-skills/rust-hexagonal.svg)](https://agentmods.dev/skills/pedromneto97/custom-skills/rust-hexagonal)
Your own site
<a href="https://agentmods.dev/skills/pedromneto97/custom-skills/rust-hexagonal"><img src="https://agentmods.dev/badge/skills/pedromneto97/custom-skills/rust-hexagonal.svg" alt="Measured on agentmods" height="20"></a>
Per session 71 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,447 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00071 $0.02447
Opus 5 $0.00036 $0.01223
Sonnet 5 $0.00014 $0.00489
Haiku 4.5 $0.00007 $0.00245

Measured 6d ago against content hash 959bfc6ece13, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

rust-hexagonal scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/rust-hexagonal/SKILL.md · 194 lines

How it starts

The opening of the file, as written. The whole thing — 194 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Hexagonal Architecture for Rust Backends

Overview

Hexagonal Architecture (Ports & Adapters) isolates the domain from all external concerns. Nothing in domain or use cases ever imports an infrastructure crate.

Call flow (always this direction):

[ HTTP / CLI / gRPC ]  →  inbound  →  use case fns(ports...)  →  domain  →  port traits  →  outbound  →  [ DB / APIs / cache / email ]

Dependencies point inward only (enforced via Cargo.toml):

app → inbound  ─┐
                ├→ domain  (model + errors + ports + use cases)
app → outbound ─┘

Typical workspace shape is four crates + one binary:

  1. domain — entities, value objects, errors, ports, use cases.
  2. inbound — HTTP/gRPC/CLI adapters; depend only on domain.
  3. outbound — DB/API/cache/email adapters; depend only on domain.
  4. migration (or migrations) — schema migrations only.
  5. app — binary; the only crate that knows all concrete types.

Is this still hexagonal? Yes. The invariant holds: domain/use cases never depend on infrastructure.

Merge use cases into domain, or keep a separate application crate?

Layout A — merge (recommended) Layout B — separate application
Crate count 4 5
domain deps may include tokio stays fully dep-free
Best for most projects shared domain across multiple services or publishing domain as a lib

async-trait rule: With Rust ≥ 1.75 and static dispatch, native async fn in traits is sufficient — no async-trait needed. Only add it if you explicitly need dyn Trait object safety.


Companion Skills

Load these skills when working on the corresponding layers:

Layer Skill Covers
Inbound (HTTP) http-actix-axum REST naming, status codes, RFC 9457 Problem Details, CORS, OWASP security headers, compression, versioning
Outbound (DB) sea-orm Migrations, entity generation, CRUD, relations, pagination, on-conflict, SeaORM v2 macros

Read the full file on GitHub · 194 lines

Files

What ships with it

8 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 194 lines · 71 tokens per session scan A 959bfc6ece13

Subscribe to this mod's changes

rust-hexagonal is a skill published in the GitHub repository pedromneto97/custom-skills (2 stars, last pushed 2mo ago), licensed MIT. It adds 71 tokens to every session and 2,447 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.