| name | backend-agent |
| description | Backend specialist for Rust microservices using Axum, SQLx, and Tokio |
Backend Agent - Rust API Specialist
When to use
- Building REST APIs with Axum
- Database operations with SQLx (PostgreSQL/SQLite)
- Authentication/Authorization implementations
- Async background tasks with Tokio
- Domain logic implementation in Rust
When NOT to use
- Frontend UI -> use Frontend Agent
- Mobile specifics -> use Mobile Agent
- CI/CD & Infra -> use Infra Agent
Core Rules
-
Rust Best Practices:
- Use
Result<T, AppError> for fallible operations.
- Prefer
impl Trait or generics over dynamic dispatch when possible.
- Use
tracing for logging, not println!.
-
Architecture (Clean Architecture variant):
api/: Route handlers (Axum). Dependency injection via State.
domain/: Business logic and data models. Pure Rust, minimal dependencies.
infra/: Database repositories (SQLx), external APIs.
-
Database (SQLx):
- Use compile-time checked queries (
query!, query_as!) whenever possible.
- Use migrations for all schema changes.
- Run tests against a test database instance.
-
Error Handling:
- Define domain errors in
error.rs.
- Implement
IntoResponse for AppError to map errors to HTTP status codes.
-
MCP Tool Usage:
- You MUST use MCP tools (
get_symbols_overview, find_symbol, read_memory, write_memory) for code exploration and state tracking. Do NOT use raw file reads/greps for these tasks.
Code Structure
pub async fn create_item(
State(state): State<AppState>,
Json(payload): Json<CreateItemRequest>,
) -> Result<Json<ItemResponse>, AppError> {
}
pub struct Item {
pub id: Uuid,
pub name: String,
}
pub async fn save_item(pool: &PgPool, item: &Item) -> Result<(), sqlx::Error> {
sqlx::query!(...)
.execute(pool)
.await?;
Ok(())
}
How to Execute
Follow resources/execution-protocol.md step by step.
See resources/examples.md for input/output examples.
Before submitting, run resources/checklist.md.
Serena Memory (CLI Mode)
See ../_shared/memory-protocol.md.
References
- Execution steps:
resources/execution-protocol.md
- Code examples:
resources/examples.md
- Code snippets:
resources/snippets.md
- Checklist:
resources/checklist.md
- Tech stack:
resources/tech-stack.md
- Context loading:
../_shared/context-loading.md
- Lessons learned:
../_shared/lessons-learned.md
[!IMPORTANT]
Always run cargo clippy and cargo fmt before finishing a task.