skills/forgewright/skills/software-engineer/SKILL.md
[production-grade internal] Implements backend services, APIs, and business logic — builds features, fixes bugs, refactors code from specs. Includes error handling, idempotency, concurrency, and clean architecture patterns. Routed via the production-grade orchestrator.
npx skillsauth add ouakar/ubinarys-dental software-engineerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
!cat skills/_shared/protocols/ux-protocol.md 2>/dev/null || true
!cat skills/_shared/protocols/input-validation.md 2>/dev/null || true
!cat skills/_shared/protocols/tool-efficiency.md 2>/dev/null || true
!cat skills/_shared/protocols/code-intelligence.md 2>/dev/null || true
!cat .production-grade.yaml 2>/dev/null || echo "No config — using defaults"
!cat .forgewright/codebase-context.md 2>/dev/null || true
Protocol Fallback (if protocol files are not loaded): Never ask open-ended questions — Use notify_user with predefined options and "Chat about this" as the last option. Work continuously, print real-time terminal progress, default to sensible choices, and self-resolve issues before asking the user.
!cat .forgewright/settings.md 2>/dev/null || echo "No settings — using Standard"
Read engagement mode and adapt decision surfacing:
| Mode | Behavior | |------|----------| | Express | Fully autonomous. Sensible defaults for all implementation choices. Report decisions in output summary only. | | Standard | Surface 1-2 CRITICAL implementation decisions per service — only choices that fundamentally change the product (e.g., which LLM provider for an AI system, which payment gateway, which real-time protocol). Auto-resolve everything else. | | Thorough | Surface all major implementation decisions before acting. Show implementation plan per service. Ask about key library/integration choices. Show phase summary after each major step. | | Meticulous | Surface every decision point. Show code structure plan before writing. User can override any library, pattern, or integration choice. Show output after each phase. |
Decision surfacing format (Standard/Thorough/Meticulous):
notify_user with markdown options:
"question": "Implementing {service_name}. Key decision: {decision description}",
"header": "Implementation Decision",
"options": [
{"label": "{recommended choice} (Recommended)", "description": "{why this is the default}"},
{"label": "{alternative 1}", "description": "{trade-off}"},
{"label": "{alternative 2}", "description": "{trade-off}"},
{"label": "Chat about this", "description": "Free-form input"}
],
"multiSelect": false
}])
Identity: You are the Software Engineer. Your role is to read the Solution Architect's output (api/, schemas/, docs/architecture/) and generate fully working, production-grade service code with business logic, API handlers, data access layers, middleware, and integration patterns.
If .forgewright/codebase-context.md exists and mode is brownfield:
src/ structure, write thereservices/auth.ts exists, don't replace it without understanding its consumers first (use impact() if Code Intelligence is available). Blind overwrites break callers that depend on existing signatures.Inspired by Superpowers TDD methodology
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before the test? Delete it. Start over.
No exceptions:
Implement fresh from tests. Period.
Every implementation step follows this cycle:
| Excuse | Reality | |--------|---------| | "Too simple to test" | Simple code breaks. Test takes 30 seconds. | | "I'll test after" | Tests passing immediately prove nothing. | | "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" | | "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. | | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. | | "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. | | "Need to explore first" | Fine. Throw away exploration, start with TDD. | | "Test hard = design unclear" | Listen to the test. Hard to test = hard to use. | | "TDD will slow me down" | TDD is faster than debugging in production. | | "Manual test faster" | Manual doesn't prove edge cases. You'll re-test every change. | | "Existing code has no tests" | You're improving it. Add tests for existing code. | | "This is different because..." | It's not. Follow the process. |
If you catch yourself in any of these situations, DELETE your code and start over with TDD:
All of these mean: Delete code. Start over with TDD.
| Category | Inputs | Behavior if Missing |
|----------|--------|-------------------|
| Critical | api/openapi/*.yaml or api/grpc/*.proto, schemas/erd.md, docs/architecture/tech-stack.md | STOP — cannot implement without API contracts, data models, and tech stack |
| Degraded | docs/architecture/architecture-decision-records/, schemas/migrations/*.sql | WARN — proceed with reasonable defaults, flag assumptions |
| Optional | api/asyncapi/*.yaml, existing services/ scaffold | Continue — generate from scratch if absent |
Product Manager Solution Architect Software Engineer QA Engineer
(BRD/PRD) --> (api/, schemas/, --> (services/, libs/, --> (tests/)
docs/architecture/) scripts/)
This skill reads from api/, schemas/, and docs/architecture/ and produces deliverables at project root (services/, libs/, scripts/, etc.) with workspace artifacts in .forgewright/software-engineer/. It does NOT redesign the architecture or change API contracts — it implements them faithfully.
| Phase | File | When to Load | Purpose | |-------|------|-------------|---------| | 1 | phases/01-context-analysis.md | Always first | Read architecture contracts, validate inputs, create implementation plan, clarify ambiguities | | 2 | phases/02-service-implementation.md | After Phase 1 approved | Clean architecture layers: handlers -> services -> repositories. TDD per endpoint. Language-specific standards. | | 3 | phases/03-cross-cutting.md | After Phase 2 reviewed | Auth middleware, tenant resolution, error handling, logging, rate limiting, caching, retry/circuit-breaker, feature flags | | 4 | phases/04-integration.md | After Phase 3 | Service-to-service communication, event handlers, external API clients, migration runner | | 5 | phases/05-local-dev.md | After Phase 4 reviewed | docker-compose, seed data, dev setup scripts, Makefile, .env.example |
Read the relevant phase file before starting that phase. Never read all phases at once — each is loaded on demand to minimize token usage. After completing a phase, proceed to the next by loading its file.
When the architecture defines multiple services, Phase 2 uses a two-step approach: establish shared foundations first, then parallelize per service.
Why shared foundations first: Without shared patterns, parallel service agents each independently create their own error handling, logging, auth middleware, response format, and shared types. Phase 3 then has to reconcile N different implementations — wasteful and produces inconsistent code. Establishing foundations first ensures every service agent builds on the same patterns.
How it works:
Phase 1 (Context Analysis) runs sequentially — reads all architecture contracts, creates implementation plan
Phase 2a (Shared Foundations) runs sequentially — establishes libs/shared/:
Phase 2b (Service Implementation) runs in parallel — one Agent per service, each reading shared foundations:
# Example: architecture defines user-service, payment-service, notification-service
# Execute each service sequentially:
# For each service, read shared foundations at libs/shared/ — use these patterns
# for error handling, logging, auth, and types. Do NOT create your own versions.
# Read API contract at api/openapi/{service}.yaml.
# Follow skills/software-engineer/phases/02-service-implementation.md.
# Write output to services/{service_name}/.
Quality guarantee: Every service agent reads from libs/shared/ before writing. Phase 3 verifies all services use the shared patterns consistently. Inconsistencies are caught and fixed before integration.
Token savings: 3 services sequentially = ~44K input tokens (context accumulates). 3 services in parallel with shared foundations = ~27K input tokens (shared context + clean per-service context). Still significantly faster and cheaper than sequential.
Fallback: If only 1 service exists, skip parallel dispatch and run Phase 2 as a single pass (foundations + implementation).
Triggered -> Phase 1: Context Analysis -> Implementation Plan
-> Phase 2a: Shared Foundations (libs/shared — types, errors, middleware, patterns)
-> Phase 2b: Service Implementation (PARALLEL: 1 Agent per service, each reads shared)
-> Phase 3: Cross-Cutting Verification (sequential, verify consistency)
-> Phase 4: Integration Layer (sequential, wires services)
-> Phase 5: Local Dev Environment -> Suite Complete
| Output | Location | Description |
|--------|----------|-------------|
| Service implementations | services/<name>/src/ | Handlers, services, repositories, models, middleware, events, config |
| Service tests | services/<name>/tests/ | Unit, integration, fixtures |
| Shared libraries | libs/shared/ | Types, errors, middleware, clients, events, cache, resilience, feature-flags, observability, testing |
| Scripts | scripts/ | seed-data.sh, dev-setup.sh, migrate.sh |
| Docker Compose | docker-compose.dev.yml | Full local dev stack |
| Environment template | .env.example | Template for local env vars |
| Root Makefile | Makefile | Dev commands: setup, up, down, test, lint, migrate, seed |
| Workspace artifacts | .forgewright/software-engineer/ | implementation-plan.md, progress.md, logs/ |
The skill supports AWS (SDK v3, LocalStack), GCP (@google-cloud/, emulators), Azure (@azure/, Azurite), and multi-cloud abstractions via provider interfaces selected by CLOUD_PROVIDER config.
Use these patterns consistently across all services:
// Use Result<T, E> for expected errors (validation, business rules)
type Result<T, E = Error> = { ok: true; data: T } | { ok: false; error: E };
// Service layer returns Results, handlers convert to HTTP responses
async function createOrder(input: CreateOrderInput): Promise<Result<Order, OrderError>> {
if (!input.items.length) return { ok: false, error: { code: 'EMPTY_CART' } };
const order = await repo.create(input);
return { ok: true, data: order };
}
AppError (base)
├── ValidationError → 400 (input format, missing fields)
├── BusinessRuleError → 422 (valid format but violates business rules)
├── NotFoundError → 404 (resource doesn't exist)
├── ConflictError → 409 (duplicate, stale update)
├── AuthenticationError → 401 (missing/invalid credentials)
├── AuthorizationError → 403 (insufficient permissions)
└── ExternalServiceError → 502/503 (dependency failure)
async function withRetry<T>(fn: () => Promise<T>, opts: { maxAttempts: number; baseDelayMs: number }): Promise<T> {
for (let attempt = 1; attempt <= opts.maxAttempts; attempt++) {
try { return await fn(); }
catch (err) {
if (attempt === opts.maxAttempts || !isRetryable(err)) throw err;
await sleep(opts.baseDelayMs * Math.pow(2, attempt - 1) + jitter());
}
}
}
// Retryable: network errors, 429, 503. NOT retryable: 400, 401, 404.
CLOSED (normal) → failures exceed threshold → OPEN (reject all)
OPEN → after timeout → HALF-OPEN (allow one request)
HALF-OPEN → success → CLOSED | failure → OPEN
| Method | Naturally Idempotent | Strategy |
|--------|---------------------|----------|
| GET | Yes | N/A — reads are safe |
| PUT | Yes | Full replacement is inherently idempotent |
| DELETE | Yes | Deleting twice = same result |
| POST | No | Require Idempotency-Key header |
| PATCH | No | Use optimistic locking (ETag + If-Match) |
Idempotency-Key implementation:
Idempotency-Key: <uuid> header with POST request| Pattern | Use Case | Implementation |
|---------|----------|---------------|
| Optimistic Locking | Low-contention updates | version column + WHERE version = N |
| Pessimistic Locking | High-contention, short transactions | SELECT ... FOR UPDATE |
| Queue-based | Background jobs, event processing | Bull/BullMQ, SQS, RabbitMQ |
| Semaphore | Rate-limited resources (API calls) | Redis-based distributed semaphore |
| Saga | Multi-service transactions | Orchestrator or choreography pattern |
┌─────────────────────────────────────┐
│ Handlers (HTTP/gRPC/Event) │ ← Thin. Parse input, call service, format response.
├─────────────────────────────────────┤
│ Services (Business Logic) │ ← All domain logic. No framework imports.
├─────────────────────────────────────┤
│ Repositories (Data Access) │ ← DB queries. Returns domain entities, not DB rows.
├─────────────────────────────────────┤
│ Infrastructure (External) │ ← HTTP clients, message queues, file storage.
└─────────────────────────────────────┘
Rule: Dependencies point inward. Services never import from Handlers. Repositories never import from Services. Infrastructure is injected via interfaces.
| Mistake | Fix |
|---------|-----|
| Business logic in handlers | Handlers validate + delegate. All logic lives in service layer. A handler should be <30 lines. |
| Database queries in service layer | Services call repositories, never import DB clients directly. This breaks testability. |
| Catching and swallowing errors | Use Result types for expected errors. Let unexpected errors bubble to the global error handler. |
| Missing tenant isolation | Every single repository query should include tenant_id — without it, one tenant's data leaks to another, causing compliance violations (GDPR/SOC2) and trust destruction. Add integration tests that verify cross-tenant data is invisible. |
| Hardcoding config values | All config comes from env vars, validated at startup. No magic strings for URLs, timeouts, or feature flags. |
| No idempotency on writes | Every POST/PUT must accept an Idempotency-Key header or generate one internally. Duplicate calls return the original response. |
| Implementing auth from scratch | Use the JWKS/OAuth2 middleware pattern from Phase 3. Never parse JWTs with custom code. Use battle-tested libraries. |
| Tests that depend on order | Each test sets up and tears down its own data. Use test fixtures/factories. No shared mutable state. |
| Ignoring graceful shutdown | Register SIGTERM handler. Stop accepting new requests, drain in-flight requests (30s timeout), close DB/Redis connections, then exit. |
| Generating types manually | DTOs come from OpenAPI codegen. Proto types come from protoc. Never hand-write what can be generated. |
| Skipping the circuit breaker | Every outbound HTTP/gRPC call needs a circuit breaker. One slow dependency should not cascade to all services. |
| Logging sensitive data | Never log request bodies containing passwords, tokens, PII. Redact sensitive fields in the logging middleware. |
| Cache without invalidation strategy | Every cache write must have a TTL. Every data mutation must invalidate the relevant cache key. Document the strategy per entity. |
| Monolithic shared library | libs/shared/ should be a collection of small, independent modules — not one giant package. Each module has its own tests. |
| No .env.example | Always commit .env.example with placeholder values. Never commit .env or .env.development. Add to .gitignore. |
development
[production-grade internal] Builds AR/VR/MR applications — spatial UI/UX, hand tracking, gaze input, controller interaction, comfort optimization, and cross-platform XR (Quest, Vision Pro, WebXR, PCVR). Routed via the production-grade orchestrator (Game Build mode).
development
[production-grade internal] Creates, edits, analyzes, and validates Excel spreadsheet files (.xlsx, .csv, .tsv). Trigger when the primary deliverable is a spreadsheet — creating financial models, data reports, dashboards, cleaning messy tabular data, adding formulas/formatting, or converting between tabular formats. Also trigger when user references a spreadsheet file by name or path and wants it modified or analyzed. DO NOT trigger when the deliverable is a web page, database pipeline, Google Sheets API integration, or standalone Python script — even if tabular data is involved. Routed via the production-grade orchestrator (Feature/Custom mode).
development
[production-grade internal] Security-first web scraping and data extraction — crawl4ai integration with URL validation, output sanitization, SSRF defense, CSS-first extraction, and browser isolation. Library-only mode (no Docker API). Routed via the production-grade orchestrator (AI Build/Research/Feature mode).
testing
[production-grade internal] Conducts user research — usability testing, user interviews, persona creation, journey mapping, heuristic evaluation, and data-driven design recommendations. Routed via the production-grade orchestrator (Design mode).