c_agri_trade/process/.agents/skills/up-code-generate/SKILL.md

8.2 KiB

name description
up-code-generate Generate production-grade backend services, frontend views/screens, database migrations, API contracts, and integration adapters for the stories in the current iteration's backlog, with explicit delivery-surface coverage across portal/frontend, API, data, integration, infrastructure, and QA. Use this after up-wireframe-spec and up-test-model-generate have produced the iteration's screens, surface matrix, and test cases. Covers Stage 13 (Construction) of the UP-AI v1.0 Process (process/AI_Native_Unified_Process_v1.md).

up-code-generate — Stage 13 (Construction, per iteration)

Objective

Implement the current iteration's stories as production-grade code — backend services, frontend screens/views, database migrations, API contracts, and integration adapters — adhering to the technology stack configured in tech-profile.yaml and requirement-driven development principles.

When to invoke

  • After up-wireframe-spec and up-test-model-generate have produced this iteration's screens and test cases.
  • Repeatedly within an iteration, once per story or logical group of related stories.

Read first

  • tech-profile.yaml (specifies backend language, framework, ORM, migrations, frontend framework, auth provider, and sandboxes)
  • Current iteration's project_sdlc/05_iteration_planning/iterations/iteration-NN/iteration_backlog.md (STORY-xxx list)
  • Current iteration's iteration_surface_matrix.md (required delivery surfaces and owners)
  • Current iteration's parallel_work_plan.md (if parallel lanes are active)
  • Owning project_sdlc/04_architecture_design/lld/LLD-0xx_*.md (API/table/event contracts)
  • Owning use case's functional-reqs.md (acceptance criteria, validation, audit requirements)
  • This iteration's wireframes (project_sdlc/06_wireframes/) and test cases (project_sdlc/07_test_design/)
  • project_sdlc/06_wireframes/DESIGN.md or active design system tokens
  • architecture_spike_report.md (service template conventions)

Procedure

Pick the next STORY-xxx with status "Ready" from the iteration backlog. Implement only that story (or related group) per invocation:

Confirm every applicable surface in iteration_surface_matrix.md has an owner and repository path. If the story requires a frontend screen, frontend code is mandatory unless an approved CR-xxx/DEC-xxx explicitly defers it.

Backend service generation: Implement against the LLD API contract exactly — request/response shapes, status codes, error format, RBAC checks, tenant-context propagation, validation, and audit logging. Use the backend language/framework specified in tech-profile.yaml.

  • When framework: frappe, organize code within the target Frappe App, authoring DocType controllers (<doctype>.py), whitelisted remote procedures (@frappe.whitelist()), server scripts, and event hooks (hooks.py).
  • When framework: django or fastapi or spring_boot, implement service controllers, repositories, and API routers matching LLD endpoint contracts. Write unit and integration tests covering the story's acceptance criteria. Add or update API collections (Bruno .bru or OpenAPI spec) for added/changed endpoints.

Frontend screen generation: Implement against the iteration's wireframe/field-level spec — fields, validation, navigation, error states.

  • When frontend.framework: frappe_desk, configure DocType FormViews, ListViews, Workspaces, and client scripts (<doctype>.js), or custom Vue/React SPAs using @frappe/ui.
  • When standard React/Vue/Angular, reuse DESIGN.md component library, tokens, and Tailwind/shadcn controls. Write corresponding component and browser-E2E tests (e.g. Playwright) tagged with UC-xxx/FR-xxx/STORY-xxx.

Database implementation: Generate schema matching the LLD table definitions via the migration mechanism configured in tech-profile.yaml:

  • When framework: frappe, author DocType schema JSON files (<doctype>.json) with fieldtypes, options, and permissions, synchronized into MariaDB/PostgreSQL via bench migrate.
  • When SQLAlchemy/Django/Spring Boot/Prisma, generate migration files via Alembic, Django migrations, Flyway, or Prisma; do not hand-edit schema outside migrations.

Integration adapters: Implement external API triggers, requests, and failure handling against the contracts in tech-profile.yaml. Consume and verify against the Wave 0 Sandbox/Mock adapters so test suites run 100% deterministically and offline without external API dependencies.

Rules (apply to every story):

  1. Do not introduce unrelated changes or refactor unrelated files.
  2. Write unit/integration/contract/smoke/browser-E2E tests assigned to this story by up-test-model-generate.
  3. Implement validation, error handling, structured logging, and audit trails where the FR requires it.
  4. Enforce tenant isolation and authorization per the architecture spike's validated pattern.
  5. Update iteration_surface_matrix.md with implementation status and verification evidence. In traceability_graph.md, transition requirement status to Implemented (Domain/Schema) upon code and unit test completion. DO NOT mark requirements as Delivered at this stage; Delivered (E2E Verified) is reserved for Gate 14.1 closure after all delivery surfaces, migrations, and dual QA assets pass.
  6. Do not place secrets, live tokens, or production credentials in code, fixtures, logs, or commits.
  7. Strict Anti-Placeholder Rule: Stub functions, mock controllers where real database logic was specified, and zero-coverage test stubs are strictly forbidden. All code must implement genuine business logic. Every web portal/screen declared in iteration_surface_matrix.md must have a physical, genuine frontend view implementation (.tsx/.vue) on disk wired via typed API clients and registered in the application router. Ghost screens or unimplemented UI placeholders cannot be marked as Delivered (E2E Verified) and will fail Gate 14.1 check G14-013.
  8. Automated Test Coverage Budgets: Ensure code meets the thresholds configured in tech-profile.yaml:
    • Backend Domain & FSMs: ≥95.0% statement and branch coverage.
    • Integration Adapters: ≥90.0% against Wave 0 sandboxes.
    • Frontend UI Components: ≥80.0% component branch coverage + mandatory Playwright browser-E2E tests for primary user journeys. Exercise Happy Path, Alternate/Boundary, Failure, and FSM Invariant scenarios.
  9. Automated OpenAPI Client Code Generation: When building frontend consumers for backend APIs, run automated client type generation (e.g., npm run codegen:api via openapi-typescript or orval). AI agents are strictly prohibited from handwriting custom TypeScript interfaces for backend entities, preventing response envelope and property drift.
  10. Strict Zero Silent Mock Fallback Rule (G14-017): Frontend components are strictly prohibited from falling back to hardcoded mock arrays or dummy objects when live API calls fail or return unexpected envelope keys (e.g. if (res && res.orders) setOrders(res.orders) else setOrders([mock])). API failures must render an explicit error boundary, alert banner, or empty state. Camouflaging API contract drift with silent mock fallbacks violates the anti-placeholder rule and fails Gate 14.1 with error G14-017.
  11. Single-Source Navigation RBAC Parity (G14-015): Frontend navigation configurations (App.tsx / ALL_NAV_ITEMS) must derive permissions directly from backend ROLE_PERMISSIONS and auth_matrix.yaml. Manually guessed or mismatched allowedRoles arrays violate Segregation of Duties and fail Gate 14.1 check G14-015.

Output expected

Source code changes; updated OpenAPI / Bruno specs in docs/api/bruno/; DB migrations; frontend portal artifacts; updated iteration_surface_matrix.md; requirement status transitioned to Implemented (Domain/Schema); execution log.

Exit criteria

Story implemented per LLD contract and screen spec across every applicable surface; API, data, integration, and frontend artifacts are synchronized; tests achieve configured coverage thresholds; requirements transitioned to Implemented (Domain/Schema); ready for up-defect-fix and Gate 14.1.

Previous: up-wireframe-spec, up-test-model-generate. Next: up-defect-fix (code review, defect handling), then up-traceability-gate (Gate 14.1).