Files
CASAN/.claude/agents/protocols/implement-delegation.md
T
thanhnvandClaude Opus 4.8 36a4812ef3 refactor(structure): promote app to repo root + remove redundant workspace cruft
Standard production layout: the OKR app (was nested under AINative_OKR_CASAN5/) is now
the repository root. No more wrapper directory.

- Promote AINative_OKR_CASAN5/* -> repo root (backend/ frontend/ packages/ apps/
  .specify/ docs/ infra/ nginx/ scripts/ + configs). Merge tool dirs: .gitea (kept the
  active deploy ci.yml, added harness-ci.yml + runbooks), .claude (agents/commands +
  launch.json), .github moved up.
- Remove redundant: 00_SUBMISSION_PACKAGE, scattered root notes (FPT_CASAN_Full.md,
  tu-tuong-casan.md, casan-tu-sinh..., casan_harness_assessment.md, source-review...,
  README_CASAN5_REFINED.md), casan-next-plans/ and optimize-docs/ (competition/planning
  artifacts — roadmap + design history preserved in git log / commit messages).
- Update all references to the old layout:
  - .gitea/workflows/{ci,harness-ci}.yml, .github/workflows/{ci,deploy}.yml:
    working-directory .; drop AINative_OKR_CASAN5/ prefix; .specify/{tests,scripts}
    -> packages/casan-harness/... (.specify/logs state kept)
  - .claude/launch.json, .gitea/*-runbook.md: path prefixes
  - CLAUDE.md, README.md: docs/input -> apps/okr/domain/input
  - policy-bundle.yaml: 8 policy paths -> packages/casan-harness/...; manifest re-signed
- secrets-scan.sh: fixture excludes -> new package/domain paths.

Full gate from the new root: PASS=64 FAIL=0 SKIP=3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 13:26:36 +09:00

4.4 KiB

Common Delegation Block for speckit.implement

This delegation block is used by the Boss when invoking speckit.implement in Step 10. Sub-agent already knows its own workflow — Boss only passes step-specific context.

Standard Context (always included)

feature-id: <feature-id>
module-id: <mod-id>
report-nn: <NN>
report-phase: <phase-name>
pipeline-context: docs/output/output_logs/<feature-id>/pipeline-context.yaml
mode: autonomous
language: Vietnamese

Real Execution Mandate

ALL terminal commands MUST be executed via the run tool with real output captured.

  • PROHIBITED: Documenting commands without executing, mock output, skipping npm commands.
  • REQUIRED: Use get_errors after every code edit to verify compile/lint errors are resolved.
  • REQUIRED: For frontend under frontend/, run npm install if node_modules/ does not exist.

⛔ Portable Database Schema Rules (Post-Mortem P-02, P-05)

When generating Prisma schema:

  1. Do NOT use enum in schema.prisma — SQLite does not support enums. Use String type with @default("VALUE") instead.
  2. Do NOT use @db.VarChar(), @db.Text, or any provider-specific annotations — these break when switching providers.
  3. Create backend/src/common/types/domain-enums.ts with TypeScript const arrays + derived types for all domain enumerations:
    export const ROLES = ['ADMIN', 'MANAGER', 'EMPLOYEE'] as const;
    export type Role = (typeof ROLES)[number];
    
  4. Import enums from domain-enums.ts, NEVER from @prisma/client enum types.
  5. Use provider = "sqlite" as default for local dev. Only switch to MySQL/PostgreSQL when Docker is confirmed available.

⛔ Mandatory .env File Creation (Post-Mortem P-03)

During Step 10 implementation, the agent MUST:

  1. Create backend/.env with at minimum:
    DATABASE_URL="file:./dev.db"
    JWT_SECRET=<random-generated-secret>
    JWT_REFRESH_SECRET=<random-generated-secret>
    PORT=3000
    
  2. Create backend/.env.example (same keys, placeholder values) for documentation.
  3. NEVER hardcode JWT secrets, database URLs, or API keys in source code. All secrets MUST be read from process.env.
  4. Add .env to .gitignore (but NOT .env.example).

⛔ Security: Secrets Management (Post-Mortem P-09)

  • JWT_SECRET, JWT_REFRESH_SECRET, DATABASE_URL → env-only, NEVER in source files
  • Use @nestjs/config ConfigService or process.env to read secrets at runtime
  • If technical_architecture.md says "hardcoded (workshop)" → OVERRIDE: still use env vars. Security trumps convenience.

⛔ React Frontend Quality Rules (Post-Mortem P-06, P-07)

  1. React Router future flags: When using React Router DOM v6, ALWAYS add future flags to <BrowserRouter>:
    <BrowserRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
    
  2. NEVER call navigate() during render. Use <Navigate to="..." replace /> component for conditional redirects in render body.
  3. ADMIN role queries: When implementing list/dashboard endpoints, ADMIN role MUST see ALL records (not filtered by ownerId). Add role-based query logic:
    const where = user.role === 'ADMIN' ? {} : { ownerId: user.id };
    

Step-Specific Additional Instructions

STEP 10 — Implementation + Build & Fix

Phase 1 — Implement:
Execute all tasks in docs/output/specs/<feature-id>/tasks.md phase by phase.
Track every file created/modified in the report's Artifacts section.

Phase 2 — Build & Fix:
Build the application and fix all compile/runtime errors. Do NOT launch the screen.
Execute in order:
1. Fix all compile/lint errors (get_errors → fix → repeat until zero)
2. Build frontend: cd frontend && npm install && npm run build
3. Start Docker (if docker-compose.dev.yml exists): docker compose -f docker/docker-compose.dev.yml up -d
4. Build backend: cd backend && npm install && npm run build
5. Verify startup (if Docker available): cd backend && npm run start:dev

UI Layout Convention (for frontend work)

Read docs/technical_architecture.md §IV for all UI layout rules. Shared components: AppLayout.jsx, SystemHeader.jsx, ModuleNav.jsx under frontend/src/components/shared/ Create if not exist, reuse if they do. Wrap ALL page components in <AppLayout>.