backend-dev-guidelines
Core standards for backend engineering. Focuses on performance, security, and maintainable service architecture. Use when building APIs, background workers, or data services.
SKILL.mdskills/backend-dev-guidelines/SKILL.md
GitHubBackend Development Guidelines
Purpose
Ensure all backend code follows Antigravity production standards: highly performant, securely isolated, and easy to audit.
When to Use This Skill
Use when implementing server-side logic, database handlers, or integration services.
Phase 1: Architecture & Data Modeling
- Define the service contract (API spec).
- Design the database schema for scalability and query efficiency.
- Identify external dependencies and security requirements.
Phase 2: Core Implementation
- Implement logic with strict input validation.
- Use asynchronous patterns for all I/O operations.
- Ensure proper error handling and logging.
- Security Enforcement:
- Sanitization: Use
DOMPurify.sanitize()(if outputting to frontend) or strict ORM bindings for all dynamic content. - Secrets: Scan for
API_KEY,TOKEN,SECRETin all staged files. Never log PII or credentials.
- Sanitization: Use
Phase 3: Verification
- Are all inputs sanitized?
- Is there a retry logic for external services?
- Are logs informative and free of PII?
Output Format / Delivery
- Implementation plan or code changes.
- Audit report for existing logic.
Behavior Rules
- Never skip validation. Even for internal services.
- Prefer statelessness. Minimize server-side session state.
- Auditability first. All major state changes must be logged.
Hard Usage Rules (Tier 2: Conditional)
- ALLOWED: Writing standard CRUD or middleware.
- FORBIDDEN: Implementing distributed state management without explicit architectural approval.
- CONSTRAINT: Must verify ORM methods against actual schema definition before generation.
Safety Guardrails & Patched Prevention
- ORM Hallucination Patch: Before writing DB queries, strictly cross-reference the exact ORM syntax documented in the workspace. Do not invent arguments (e.g.,
includeAll). - Missing Indexes Patch: If generating a
WHEREorJOINclause on a non-primary key, append a mandatory comment flagging the need for a database index. - Sync I/O Patch: All file system operations must use
fs.promises. Synchronous methods (readFileSync) are strictly forbidden. - Self-Rejection Clause: If the output cannot be proven to satisfy its patches (e.g., missing schema context to guarantee ORM safety), ABORT OUTPUT and emit: "REJECTED: Missing schema context to guarantee ORM safety."
Maintenance Notes
- Initial global core skill.