Backend Guidance
This is a composable overlay, not a standalone workflow.
Use alongside the matching principle skill (for example,
coding-guidance-cpp) when the change touches backend code. Add
project-core-dev only when repository-specific completion checks still need
to be discovered or reported.
Choose the activity before applying the rules below:
- for implementation, make only the requested backend changes and validate them
- for review, inspect and report prioritized findings with evidence; do not
edit files or require findings to be fixed unless the user also asks for
remediation
Use this as the thin default backend overlay for ordinary backend work.
If the task includes service-boundary refactors, repository or transaction work,
queue or webhook reliability, stronger testing expectations, or explicit
trust-boundary hardening, prefer backend-systems-guidance.
Routing examples:
- thin route handler that delegates to existing service logic -> use this skill
- small message consumer bug fix with no retry or persistence redesign -> use
this skill
- new endpoint with authz, repository, transaction, retry, or observability
changes -> use
backend-systems-guidance
- security audit of an endpoint or tenant membership/authorization boundary ->
use
security first; add security-identity-access when identity, session,
or tenant authorization is central, and add the backend overlay only for
implementation structure
When to use
The repo has server-side networked code: HTTP route handlers, gRPC service
methods, message/event consumers, or similar request-processing pipelines.
Not for
HTTP client code, CLI tools that make outbound requests, batch processors, or
offline data pipelines. These do not have the handler/service/boundary shape
this skill addresses.
Rules
- Keep handlers thin in responsibility, not by literal line count — parse
input, call a service function, map transport concerns, serialize output. If
a handler starts owning business decisions, extract that logic into a service
or core module.
- Keep business logic testable without transport — no HTTP context, no gRPC
metadata leaking into domain functions.
- Isolate data access behind an interface when it simplifies testing. Do not
add an abstraction layer when the data access is trivial or test-only.
- Decode, normalize, and validate the external transport shape at the untrusted
boundary before it reaches business logic. Do not confuse that check with
domain invariants that the service or domain owner must enforce.
- Keep transport-only concerns at the edge: request decoding, authentication,
and transport-specific error mapping. Enforce authorization in the earliest
shared policy layer that every relevant entrypoint traverses; an edge-only
authorization check is sufficient only when no other entrypoint can bypass
it.
- Keep business invariants in service or domain code and persistence invariants
in the data layer. Avoid duplicate checks that enforce the same contract, but
do not remove a check merely because another layer validates a different
concern.
- Use dependency injection where it makes tests simpler — not as a default
architectural pattern.
Decision Heuristics
- Handler responsibility: extract business decisions from transport glue
when they obscure ownership; line count alone is not an architectural defect.
- Test seam: if testing a business rule requires transport infrastructure,
move that rule inward. Tests of routing, serialization, or middleware may
correctly need a real transport boundary.
- Validation placement: validate each concern at its owning boundary:
transport shape at ingress, shared authorization before the action, domain
invariants in the domain owner, and storage constraints in persistence. If
checks are scattered, identify whether they duplicate one contract or protect
different boundaries before consolidating them.
Validation
For implementation, a backend change is done when, in addition to the base
implementation skill's validation:
- handlers delegate to testable service functions
- business logic tests run without transport dependencies
- external transport shape is validated at ingress, shared authorization cannot
be bypassed through another entrypoint, and domain invariants remain in their
owning layer
- transport-specific error handling stays at the boundary instead of leaking
into domain logic
For review, completion means prioritized findings name the affected request or
consumer path, supporting evidence, likely consequence, and validation gap.
Open findings do not make the review incomplete.
1---2name: backend-guidance3description: Baseline overlay for routine thin HTTP, gRPC, or message-consumer implementation and review; use `backend-systems-guidance` for multi-layer, data-access, transaction, reliability, or trust-boundary work. Compose with matching implementation guidance. Not for outbound-client-only or security-audit tasks.4---56# Backend Guidance78This is a composable overlay, not a standalone workflow.9Use alongside the matching principle skill (for example,10`coding-guidance-cpp`) when the change touches backend code. Add11`project-core-dev` only when repository-specific completion checks still need12to be discovered or reported.1314Choose the activity before applying the rules below:1516- for implementation, make only the requested backend changes and validate them17- for review, inspect and report prioritized findings with evidence; do not18 edit files or require findings to be fixed unless the user also asks for19 remediation2021Use this as the thin default backend overlay for ordinary backend work.22If the task includes service-boundary refactors, repository or transaction work,23queue or webhook reliability, stronger testing expectations, or explicit24trust-boundary hardening, prefer `backend-systems-guidance`.2526Routing examples:2728- thin route handler that delegates to existing service logic -> use this skill29- small message consumer bug fix with no retry or persistence redesign -> use30 this skill31- new endpoint with authz, repository, transaction, retry, or observability32 changes -> use `backend-systems-guidance`33- security audit of an endpoint or tenant membership/authorization boundary ->34 use `security` first; add `security-identity-access` when identity, session,35 or tenant authorization is central, and add the backend overlay only for36 implementation structure3738## When to use3940The repo has server-side networked code: HTTP route handlers, gRPC service41methods, message/event consumers, or similar request-processing pipelines.4243## Not for4445HTTP client code, CLI tools that make outbound requests, batch processors, or46offline data pipelines. These do not have the handler/service/boundary shape47this skill addresses.4849## Rules5051- Keep handlers thin in responsibility, not by literal line count — parse52 input, call a service function, map transport concerns, serialize output. If53 a handler starts owning business decisions, extract that logic into a service54 or core module.55- Keep business logic testable without transport — no HTTP context, no gRPC56 metadata leaking into domain functions.57- Isolate data access behind an interface when it simplifies testing. Do not58 add an abstraction layer when the data access is trivial or test-only.59- Decode, normalize, and validate the external transport shape at the untrusted60 boundary before it reaches business logic. Do not confuse that check with61 domain invariants that the service or domain owner must enforce.62- Keep transport-only concerns at the edge: request decoding, authentication,63 and transport-specific error mapping. Enforce authorization in the earliest64 shared policy layer that every relevant entrypoint traverses; an edge-only65 authorization check is sufficient only when no other entrypoint can bypass66 it.67- Keep business invariants in service or domain code and persistence invariants68 in the data layer. Avoid duplicate checks that enforce the same contract, but69 do not remove a check merely because another layer validates a different70 concern.71- Use dependency injection where it makes tests simpler — not as a default72 architectural pattern.7374## Decision Heuristics7576- **Handler responsibility:** extract business decisions from transport glue77 when they obscure ownership; line count alone is not an architectural defect.78- **Test seam:** if testing a business rule requires transport infrastructure,79 move that rule inward. Tests of routing, serialization, or middleware may80 correctly need a real transport boundary.81- **Validation placement:** validate each concern at its owning boundary:82 transport shape at ingress, shared authorization before the action, domain83 invariants in the domain owner, and storage constraints in persistence. If84 checks are scattered, identify whether they duplicate one contract or protect85 different boundaries before consolidating them.8687## Validation8889For implementation, a backend change is done when, in addition to the base90implementation skill's validation:9192- handlers delegate to testable service functions93- business logic tests run without transport dependencies94- external transport shape is validated at ingress, shared authorization cannot95 be bypassed through another entrypoint, and domain invariants remain in their96 owning layer97- transport-specific error handling stays at the boundary instead of leaking98 into domain logic99100For review, completion means prioritized findings name the affected request or101consumer path, supporting evidence, likely consequence, and validation gap.102Open findings do not make the review incomplete.