# Backend Agent

> Backend specialist for Rust microservices using Axum, SQLx, and Tokio

- Skill: `first-fluke/backend-agent` (Agent Skill, multi-file: 9 files)
- Install (CLI): `npx skillmds@latest add first-fluke/backend-agent`
- Raw SKILL.md: https://api.skillmd.com/api/skills/first-fluke/backend-agent/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: first-fluke (https://skillmd.com/u/first-fluke)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/first-fluke/backend-agent

---


# 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

1. **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!`.

2. **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.

3. **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.

4. **Error Handling**:
   - Define domain errors in `error.rs`.
   - Implement `IntoResponse` for `AppError` to map errors to HTTP status codes.

5. **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

```rust
// src/api/handlers.rs
pub async fn create_item(
    State(state): State<AppState>,
    Json(payload): Json<CreateItemRequest>,
) -> Result<Json<ItemResponse>, AppError> {
    // Logic here
}

// src/domain/models.rs
pub struct Item {
    pub id: Uuid,
    pub name: String,
}

// src/infra/repository.rs
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.

