Wrap a new backend endpoint in the TypeScript SDK (packages/sdk), or record it as skipped. Use when `just coverage` fails, or after adding an endpoint to a Rust service.
日本語の概要は準備中です。原文の説明を表示しています。
Enforce hexagonal architecture in the Rust backend. Use before modifying crates/ or Rust services, especially inbound axum/tool/listener adapters, domain services/ports, outbound adapters, authorization, permissions, database access, or external clients.
インストール方法を見るインストールする前に、エージェントに与えられる指示の中身を確認できます。
Use this skill whenever you add, change, or review Rust code under crates/** or services/** that touches a crate with src/domain, src/inbound, or src/outbound.
This repository follows the ports-and-adapters / hexagonal style described in Master Hexagonal Architecture in Rust and the howtocodeit/hexarch 3-simple-service branch: domain models + ports + services are the center; inbound and outbound adapters are replaceable shells around that center.
Dependencies point inward:
inbound adapters ──► domain ports/models/services ◄── outbound adapters
composition root ──► inbound + domain service + outbound implementations
domain/ must not depend on inbound/, outbound/, axum, HTTP response types, SQLx pools/queries, AWS SDKs, Redis, reqwest, environment variables, or transport DTOs.inbound/ may depend on domain ports/models/services. It must not own business decisions or persistence/external-service implementation details.outbound/ implements domain ports for databases, S3, HTTP clients, queues, metrics, etc. It must not own use-case policy.src/domain/**)Put the following here:
src/inbound/**)Axum handlers, AI tools, Kafka/listener handlers, lambda handlers, and CLI entrypoints are adapters. Keep them thin:
MacroAuthorizationExtractor, OptionalMacroAuthorizationExtractor, JWT, signed internal header, request context).Inbound adapters must not:
entity_access, roles_and_permissions, repositories, SQLx, S3, Redis, SQS, reqwest, or other outbound implementations to make a use-case decision.AccessLevel, role, owner/admin/member, tenant/team membership, project membership, subscription tier, feature entitlement, entity state, or ownership for business policy.src/outbound/**)Put implementation details here:
Outbound adapters must not:
crate::inbound::*, axum extractors/responses, or transport DTOs.EntityAccessReceipt ruleAuthentication can happen at the edge. Entity access checks should cross the boundary as a typed capability: EntityAccessReceipt<T>.
EntityAccessReceipt<T> means the entity access layer has verified the caller has at least permission T for the entity. Inbound adapters may obtain this receipt through the standard access extractors or by calling the entity access service specifically to mint a receipt. After that, ordinary handlers/tools/listeners must pass the receipt inward instead of re-checking or branching on authorization.
Allowed in inbound:
401 / unauthenticated).actor, request_context, user_id, service identity, internal principal, or a typed EntityAccessReceipt<T>.generate_entity_access_receipt::<RequiredLevel>(...) to mint a receipt.Forbidden in ordinary inbound handlers/tools/listeners:
if user_id != owner_id { ... }if access_level < Edit { ... }entity_access_service.get_access_level(...) or can_edit(...) followed by allow/deny branching.receipt.entity_permission() to decide use-case business policy.Correct pattern:
ViewAccessLevel, EditAccessLevel, or OwnerAccessLevel.EntityAccessReceipt<RequiredLevel> using the existing entity access boundary.Unauthorized, Forbidden, or a typed policy error.Bad: the handler branches on permissions and performs the protected action itself.
pub async fn edit_document_handler(
State(state): State<DocumentRouterState>,
Json(args): Json<EditDocumentServiceArgs>,
) -> Result<Json<EditDocumentResponse>, DocumentError> {
let access_level = state
.entity_access
.get_access_level(current_user(), &args.document_id, EntityType::Document)
.await?
.ok_or(DocumentError::Unauthorized)?;
if access_level < AccessLevel::Edit {
return Err(DocumentError::Unauthorized);
}
if args.share_permission.is_some() && access_level != AccessLevel::Owner {
return Err(DocumentError::Unauthorized);
}
state.document_repo.update_document(args).await?;
Ok(Json(EditDocumentResponse::success()))
}
Good: inbound obtains a typed receipt and forwards it; the domain service owns policy and orchestration.
pub async fn edit_document_handler<T: DocumentService, Svc: EntityAccessService>(
access: DocumentAccessExtractor<EditAccessLevel, Svc>,
State(state): State<DocumentRouterState<T, Svc>>,
document_context: LoadedDocumentBasic,
project: ProjectBodyAccessLevelExtractor<EditAccessLevel, EditDocumentServiceArgs, Svc>,
) -> Result<Json<EditDocumentResponse>, DocumentError> {
state
.service
.edit_document(
access.entity_access_receipt,
document_context.into_inner(),
project.into_inner(),
)
.await?;
Ok(Json(EditDocumentResponse::success()))
}
async fn edit_document(
&self,
receipt: EntityAccessReceipt<EditAccessLevel>,
document_context: DocumentBasic,
args: EditDocumentServiceArgs,
) -> Result<(), DocumentError> {
if let EntityPermission::AccessLevel { access_level } = receipt.entity_permission() {
if args.project_id.is_some() && *access_level != AccessLevel::Owner {
return Err(DocumentError::Unauthorized);
}
if args.share_permission.is_some() && *access_level != AccessLevel::Owner {
return Err(DocumentError::Unauthorized);
}
}
let document_id = receipt.entity().entity_id.clone();
self.repo
.edit_document_metadata(document_id, document_context, args)
.await
}
Before editing code, classify each touched file:
domain, inbound, outbound, or composition/wiring?If a step has no answer, stop and design that boundary before writing code.
For every Rust backend diff, reject or refactor if any of these are true:
src/domain/** imports axum, http::StatusCode, IntoResponse, Json, Router, Request, HeaderMap, SQLx pools/queries, AWS SDK clients, Redis clients, reqwest clients, crate::inbound, or crate::outbound.src/inbound/** contains SQLx queries, transaction handling, repository calls, AWS/Redis/OpenSearch/reqwest calls, or direct calls to outbound implementations.src/inbound/** handlers/tools/listeners contain authorization decisions (AccessLevel, role checks, owner checks, team/project membership checks, can_*, authorize_*, ensure_*permission*) instead of forwarding a typed EntityAccessReceipt<T> or identity to a service. Dedicated access extractors whose job is to mint receipts are the exception.Set CRATE to the crate you are touching, for example CRATE=crates/documents.
# Domain must not know transport or concrete infrastructure.
rg -n "use (axum|http::StatusCode)|IntoResponse|Json<|Router|HeaderMap|Request<|sqlx::|PgPool|aws_sdk|redis::|reqwest|crate::inbound|crate::outbound" "$CRATE/src/domain" --glob '*.rs'
# Inbound authz/policy hits require inspection. Receipt-minting extractors are allowed;
# ordinary handlers should forward EntityAccessReceipt<T> instead of branching.
rg -n "entity_access|EntityAccessReceipt|roles_and_permissions|AccessLevel|RoleId|owner|admin|member|tenant|team|project|permission|authorize|authz|can_|ensure_.*permission|Forbidden|Unauthorized" "$CRATE/src/inbound" --glob '*.rs'
# Inbound should not do persistence or infrastructure work.
rg -n "sqlx::|query!|query_as!|PgPool|Transaction|aws_sdk|redis::|opensearch|reqwest|S3|Sqs|Dynamo" "$CRATE/src/inbound" --glob '*.rs'
# Outbound must not depend on inbound transport.
rg -n "crate::inbound|axum|IntoResponse|Json<|Router|StatusCode" "$CRATE/src/outbound" --glob '*.rs'
rg hits are not automatically failures, but every hit must be explained by layer responsibilities. When in doubt, move policy inward.
When you use this skill, explicitly state that the hexagonal boundary was checked and summarize where authz/business policy lives after your change.
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Wrap a new backend endpoint in the TypeScript SDK (packages/sdk), or record it as skipped. Use when `just coverage` fails, or after adding an endpoint to a Rust service.
日本語の概要は準備中です。原文の説明を表示しています。
Add or change an in-app feature tour (a view's guided flyover) in the web app. Use when adding a tour to a view, adding or editing tour steps, pointing a step at a new control, or when a step's target needs something opened first.
日本語の概要は準備中です。原文の説明を表示しています。
Enforce hexagonal architecture in the Rust backend. Use before modifying crates or Rust services, especially inbound axum/tool/listener adapters, domain services/ports, outbound adapters, authorization, permissions, database access, or external clients.
日本語の概要は準備中です。原文の説明を表示しています。
Use when adding collaborative markdown, notes, or descriptions to a feature with collab surfaces. Covers parent entities, service entry points, authorization, content storage, and lifecycle.
日本語の概要は準備中です。原文の説明を表示しています。
Build a new AI tool end-to-end — Rust implementation, toolset wiring, infra, schema generation, and frontend UI.
日本語の概要は準備中です。原文の説明を表示しています。
Use when building a feature on reusable database storage or UI, such as CRM, or deciding whether it needs a Macro database entity. Covers shared storage, a host-independent database UI and API contract, ownership, authorization, and the _entities naming convention.
日本語の概要は準備中です。原文の説明を表示しています。