Chalk Labs
Need help deploying backend-controller?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/davidleonmayor-backend-controller
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
backend-controller- Description
- None
- License
- MIT
- Instructions
- 206 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- missing YAML frontmatter
- name: missing
- description: missing
Files (1)
- SKILL.md
SKILL.md (first lines)
# Backend Controller
## Overview
This skill defines the convention for backend controller classes. Controllers should be **thin** - their only job is to parse the request, call the appropriate service, and format the response. All validation and auth logic belongs elsewhere.
## Trigger
When creating or updating controller classes for backend features (e.g., `auth.controller.ts`, `messaging.controller.ts`, `project.controller.ts`).
## Do's
- **Thin Controller**: Controllers should only handle HTTP concerns (parse request, call service, format response). All business logic goes in the Service layer.
- **Use Services**: Inject and use Service classes to perform business operations. Do NOT call `prisma` directly from controllers (except for simple read-only queries that are tightly coupled to the HTTP response).
- **Extract Body Data**: Destructure `req.body` to get input parameters.
- **Access Auth User**: Use `req.user` directly (after middleware has validated auth). Do NOT check if `req.user` exists - that's the middleware's job.
- **Return Proper HTTP Status Codes**: Use correct status codes (201 for created, 200 for ok, 401 for unauthorized, 404 for not found, 409 for conflict, 500 for errors).
- **Handle Errors**: Wrap controller logic in try-catch. Return user-friendly error messages. Use `next(error)` for unexpected errors to let the global error handler deal with them.
- **Type Safety**: Use proper TypeScript types for `Request`, `Response`, and custom interface types. Avoid `(req as any)`.
- **Use Custom Request Interface**: Define a custom interface that extends Express's Request to include custom properties like `user`.
## Don'ts
- **Don't Validate Data Types/Lengths/Formats**: That's the Schema's job (using `express-validator`). If a field is missing or invalid, the schema validation middleware will reject it before the controller runs.
- **Don't Check Authentication**: Do NOT check `if (!req.user)` or `if (!req.headers.authorization)`. That's the AuthMiddleware's job. If the request reached the controller, the user is authenticated.
- **Don't Check Authorization Roles**: Do NOT check `if (req.user.role === 'admin')`. That's the RoleMiddleware's job.
- **Don't Use `console.log/error`**: Use the `logger` from `config/` or simply omit logging in controllers (services should handle logging).
- **Don't Call Prisma Directly**: Except for simple queries tightly coupled to the response. Use Services for business logic.
- **Don't Re-validate Business Rules That Are Already Validated**: Don't check `if (!email)` or `if (password.length < 8)` - the schema already did this.
- **Don't Mix Responsibilities**: A controller method should do ONE thing: extract data → call ONE service method → return response.
## Example Structure
### ✅ GOOD - Thin Controller
```typescript
import type { Request, Response, NextFunction } from "express";
import { AuthService } from "./auth.service";
export class AuthController {
private authService: AuthService;
constructor() {
this.authService = new AuthService();
this.register = this.register.bind(this);
}
async register(req: Request, res: Response, next: NextFunction) {
try {
// 1. Extract data from body (already validated by schema)
const { names, lastNames, email, password } = req.body;
// 2. Check business rule (NOT data validation)
const existingPersona = await this.authService.findUserByEmail(email);
if (existingPersona) {
return res.status(409).json({
error: "El usuario ya existe",
});
}
// 3. Call service
const persona = await this.authService.createUser(
names,
lastNames,
email,
password,
);
// 4. Return response
return res.status(201).json({
message: "Usuario creado correctamente",
user: persona,
});
} catch (error: any) {
console.error("Error en register:", error);
return res.status(500).json({
error: error.message || "Ocurrió un error interno al registrar el usuario.",
});
}
}
async getUser(req: Request, res: Response, next: NextFunction) {
try {
// req.user is guaranteed to exist - middleware handled auth
const { password: _, ...safeUser } = req.user;
return res.json(safeUser);
} catch (error) {
next(error);
}
}
}
```
### ❌ BAD - Fat Controller (What NOT to Do)
```typescript
// ❌ BAD: Re-validating data that schema already validated
async register(req: Request, res: Response, next: NextFunction) {
const { names, email, password } = req.body;
// This is WRONG - schema already validated this!
if (!names || names.length < 1) {
return res.status(400).json({ error: "Name is required" });
}
if (!email || !email.includes("@")) {
return res.status(400).json({ error: "Invalid email" });
}
if (password.length < 8) {
return res.status(400).json({ error: "Password too short" });
}
// ...
}
// ❌ BAD: Checking auth that middleware already handled
async getUser(req: Request, res: Response, next: NextFunction) {
// This is WRONG - middleware already checked this!
if (!req.user) {
return res.status(401).json({ error: "No autorizado" });
}
// ...
}From davidleonmayor/proyecto-grado-unimayor, MIT.
More from davidleonmayor/proyecto-grado-unimayor
- 0.516score
backend-context
davidleonmayor
Backend architecture, patterns and conventions for the Express.js 5 API.
SkillCFreshness: C★ 3Claude Code +9 - 0.511score
ui-ux-designer
davidleonmayor
Create interface designs, wireframes, and design systems.
SkillCFreshness: C★ 3Claude Code +9 - 0.451score
frontend-context
davidleonmayor
Frontend architecture, patterns and conventions for the Next.js 15 app.
SkillDFreshness: D★ 3Claude Code +9 - 0.449score
skill-commit
davidleonmayor
Creates professional git commits following conventional-commits format.
SkillDFreshness: D★ 3Claude Code +9 - 0.437score
express-mocks-testing
gentleman-programming
Unit testing pattern for Express 5 controllers using node-mocks-http and @prisma/client mocks.
SkillCFreshness: C★ 3Claude Code +9 - 0.274score
backend-schema
davidleonmayor
No description from the publisher yet.
SkillCFreshness: C★ 3Claude Code +9 - 0.274score
backend-router
davidleonmayor
No description from the publisher yet.
SkillCFreshness: C★ 3Claude Code +9 - 0.274score
backend-service
davidleonmayor
No description from the publisher yet.
SkillCFreshness: C★ 3Claude Code +9 - 0.248score
project-info
davidleonmayor
General monorepo structure and component overview.
SkillDFreshness: D★ 3Claude Code +9 - 0.248score
skill-sync
prowler-cloud
Synchronizes skill metadata to AGENTS.md Auto-invoke sections.
SkillDFreshness: D★ 3Claude Code +9
Signals
- Stars
- 3
- Forks
- 0
- Open issues
- 1
- Last commit (this folder)
- May 2, 2026 (6 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from davidleonmayor
- 0.516score
backend-context
davidleonmayor
Backend architecture, patterns and conventions for the Express.js 5 API.
SkillCFreshness: C★ 3Claude Code +9 - 0.511score
ui-ux-designer
davidleonmayor
Create interface designs, wireframes, and design systems.
SkillCFreshness: C★ 3Claude Code +9 - 0.451score
frontend-context
davidleonmayor
Frontend architecture, patterns and conventions for the Next.js 15 app.
SkillDFreshness: D★ 3Claude Code +9 - 0.449score
skill-commit
davidleonmayor
Creates professional git commits following conventional-commits format.
SkillDFreshness: D★ 3Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get backend-controller running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
backend-controller skill. Agent Mart. https://agentmart.dev/skills/davidleonmayor-backend-controller (last updated 2026-10-24)