Bluewoo HRMS
AI Development Guide

AI Coding Agents Guide

Complete reference for AI agents building the HRMS system

AI Coding Agents Guide

This is the comprehensive guide for AI coding agents (Claude Code, Cursor, Copilot) to build a production-ready, AI-native HRMS system.

Core Philosophy

"Will this help our first 10 customers TODAY?" — Filter for all technical decisions.

This question prevents:

  • Premature abstraction
  • Over-engineering
  • Feature creep
  • Technology churn

Target Metrics

MetricTarget
Tenants100
Users10,000
DatabaseSingle PostgreSQL with RLS
ArchitectureNext.js + NestJS monolith
APIsREST (not GraphQL)
AINative from day one

What This Guide Covers

Architecture & Stack

Data & Implementation

AI Features

Development Process

UI Reference

Quick Reference

Key Patterns

// Every manager is an employee
interface EmployeeOrgRelations {
  primaryManagerId?: string        // 0..1
  dottedLineManagerIds: string[]   // 0..N
  additionalManagerIds: string[]   // 0..N
  teamIds: string[]                // 0..N
  departmentIds: string[]          // 0..N
  roleIds: string[]                // 0..N
}

Critical Rules

ALWAYS:
├── Filter by tenantId in every query
├── Use Prisma 5.x (NOT 6.x)
├── Use REST APIs (NOT GraphQL)
├── Follow established patterns exactly
└── Complete one building block before starting next

NEVER:
├── Add microservices
├── Use event sourcing
├── Create abstract factories for < 3 implementations
├── Touch locked files without ADR
└── Suggest "better" patterns

Operations Summary

// Manager operations
Org.assignPrimaryManager(empId, mgrId)
Org.addDottedLineManager(empId, mgrId)
Org.addAdditionalManager(empId, mgrId)

// Team operations
Org.addEmployeeToTeam(empId, teamId, role?)
Org.removeEmployeeFromTeam(empId, teamId)

// Department operations
Org.addEmployeeToDepartment(empId, deptId, isPrimary?)
Org.setPrimaryDepartment(empId, deptId)

// Role operations
Org.assignRole(empId, roleId, isPrimary?)
Org.setPrimaryRole(empId, roleId)

// AI operations
AI.org.explain(empId)
AI.org.validate(options)
AI.org.generateStructure(description)

Before You Start

  1. Read Architecture Principles to understand what NOT to do
  2. Check Technology Stack for locked versions
  3. Review Domain Models for the flexible org structure
  4. Understand the Workflow and gate system
  5. Check the current building block in Implementation Plan

Session Checklist

Before every coding session:

  • Read current building block specification
  • Check Constraints for hard rules
  • Review Patterns for code structure
  • Check what files are locked
  • Understand current system state

Live State Files (CRITICAL)

MANDATORY

Before EVERY coding session, these files MUST exist and be current in the code repository root.

FilePurposeAI Must Read
PROJECT_STATE.mdCurrent progress, step-level tracking✅ FIRST
WHAT_EXISTS.mdInventory of built components✅ SECOND
CLAUDE.mdClaude Code instructions✅ AUTO

Session Start Ritual

Before writing ANY code:

  1. Read PROJECT_STATE.md - Know current phase, step, locked files
  2. Read WHAT_EXISTS.md - Know what's built, patterns to copy
  3. Check git status - Verify clean state
  4. State understanding: "I'm on Phase X, Step Y. I will do Z."
  5. WAIT for approval

After EVERY Step

Update PROJECT_STATE.md:

  • Mark step ✅ with timestamp
  • Update current step section
  • Update progress percentage

See Live State Tracking for complete templates and protocols.


CLAUDE.md Template

Create this file at the root of the hrms code repository. Claude Code automatically reads this file at the start of every session.

# HRMS Project - AI Agent Instructions

## Project Context
Multi-tenant HRMS SaaS with flexible org structure.
- Monorepo: apps/web (Next.js 15), apps/api (NestJS 10), packages/database (Prisma 5)
- Database: PostgreSQL 17 with Row-Level Security
- Auth: Auth.js with Google SSO

## Current Phase
Check: https://hrms-docs.vercel.app/docs/15-implementation-plan

## CRITICAL RULES

### Session Start Ritual (MANDATORY)
1. Read PROJECT_STATE.md - Note current phase, step, locked files
2. Read WHAT_EXISTS.md - Note patterns to copy
3. Run: git status && git log -3 --oneline
4. State: "I'm on Phase X, Step Y. I will do Z. Pattern source: [file]."
5. WAIT for approval before any code changes

### Before Writing Code
1. Complete Pre-Code Verification (see below)
2. Confirm understanding: "I will [X]. Gate is [Y]. Proceed?"
3. Wait for approval

### After Each Step
1. Update PROJECT_STATE.md with ✅ and timestamp
2. Run gate verification
3. Report: "Gate [PASS/FAIL]: [details]"
4. Ask: "What's next?" - DO NOT auto-proceed

### Escape Hatch
If unsure about ANYTHING, ASK instead of guessing.

## PRE-CODE VERIFICATION (Before EVERY Edit)

1. Is this file in "Locked Files" list? → STOP if yes
2. Have I read the file's current contents? → Read first if no
3. Does similar file/component exist? → Search first
4. What pattern am I copying from? → Identify source file
5. What is the gate for this step? → State criteria

## CONSTRAINTS - DO NOT VIOLATE

### Architecture
- NO microservices (monolith only)
- NO GraphQL (REST only)
- NO event sourcing or message queues
- NO abstractions without 3+ implementations

### Technology
- Prisma 5.x (NOT 6.x)
- Next.js 15.x with App Router
- NestJS 10.x
- React Query (NOT Redux/MobX)

### Development
- Complete ONE vertical slice before touching anything else
- Never modify locked files without approval
- Never install packages not in tech stack
- Never suggest "improvements" to working code

## ANTI-IMPROVEMENT PLEDGE

NEVER do these without explicit request:
- "Improve" working code
- Suggest "better" alternatives
- Refactor "while we're here"
- Add "helpful" features
- "Clean up" unrelated code
- Premature optimization
- Add extra error handling
- Create abstractions for single use

If tempted, ask: "Is [X] in scope? If not, I'll continue with current task."

## Common Commands
# Development
npm run dev              # Start all services
npm run db:push          # Push schema changes
npm run db:studio        # Open Prisma Studio

# Testing
npm test             # Run tests
npm run lint             # Run linter

# Build
npm run build            # Build all

## Key Files
- packages/database/prisma/schema.prisma - Database schema
- apps/api/src/app.module.ts - API module registration
- apps/web/app/layout.tsx - App layout

## Anti-Patterns (From Bluewoo Lessons)
- Over-engineering for hypothetical scale
- Adding features "for later"
- Enterprise patterns for zero customers
- Shared libraries between modules
- Complex inheritance hierarchies

Why CLAUDE.md?

From industry research:

  • Claude automatically loads this file into context
  • Reduces repetitive instructions
  • Prevents common mistakes consistently
  • Higher payoff than MCP servers for single-developer projects

Updating CLAUDE.md

Update when:

  • Moving to a new phase
  • Adding new constraints
  • Discovering recurring mistakes
  • Changing tech stack (with ADR)