OpenHRApp / Others
CLAUDE.md26 starsChanged 7 months agoMITView on GitHub
ALL contributors (human or AI) MUST read and follow these instructions. For all web browsing, use the /browse skill from gstack. Never use mcp__claude-in-chrome__* tools for browsing. First-time setup (all contributors must run once): Prerequisites: bun must be installed. The script clones gstack to ~/.claude/skills/gstack/ and runs ./setup. Available gstack skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /design-shotgun, /design-html, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /connect-chrome, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /setup-gbrain, /retro, /investigate, /document-release, /document-generate, /codex, /cso, /autoplan, /plan-devex-review, /devex-review,…
- Commits and pushes
In this repository9 other files it gives its agents.
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- public/llms-full.txtllms.txt
- public/llms.txtllms.txt
- frontend-designSkill
- seo-auditSkill
- theme-factorySkill
- vercel-react-best-practicesSkill
- web-design-guidelinesSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
23 rules. About 0 are common, 13 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 83
If workflow approverRole = HR/ADMIN → status = PENDING_HR (skip manager)
- Very specific: line 84
If employee has no lineManagerId ("Reports To" on the employee form.
- Distinctive: line 88
Leave balance = quota[type] - sum(approved_days[type])
- Distinctive: line 97
Check overrides for active date range
- Very specific: line 98
Use employee's assigned shift (shiftId)
- Distinctive: line 99
Use organization default shift
- Very specific: line 113
All images auto-converted to WebP via convertToWebP() utility
- Very specific: line 149
ALL native-feature components MUST have an <ErrorBoundary> wrapper
- Distinctive: line 150
Always handle permission-denied / no-geolocation errors with readable messages
- Distinctive: line 152
Test camera + location on real iOS Safari and Android Chrome before shipping (PWA standalone mode is stricter than the browser tab)
- Very specific: line 167
All native feature components must have <ErrorBoundary> wrapper
- Distinctive: line 168
Use custom hooks for camera and location — never call plugins directly
- Distinctive: line 169
All user-facing errors must show readable messages, never raw JS errors
- Distinctive: line 170
All images must be auto-converted to WebP before upload
- Distinctive: line 171
Never delete or modify existing notification/email logic without explicit approval
- Very specific: line 172
Always include organization_id in new records for multi-tenant isolation
- Distinctive: line 184
After completing any code changes:
- Very specific: line 186
Commit with a descriptive message: git commit -m "description of changes"
- Distinctive: line 189
Always push immediately after committing.
- Distinctive: line 230
Add or update a regression check — unit test when the test framework lands, or a documented manual verification in the commit message until …
- Very specific: line 233
Update src/data/changelog.ts with a fix or change entry.
- Very specific: line 234
Never bypass hooks or skip validation on the commit (--no-verify is forbidden).
- Distinctive: line 276
Before shipping any change touching frozen files:
≈ “Common” is an estimate: at least 1 in 5 of the 28,633 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ALL contributors (human or AI) MUST read and follow these instructions.
gstack — Web Browsing & Skills
For all web browsing, use the /browse skill from gstack. Never use mcp__claude-in-chrome__* tools for browsing.
First-time setup (all contributors must run once):
powershell -ExecutionPolicy Bypass -File scripts/setup-gstack.ps1Prerequisites: bun must be installed. The script clones gstack to ~/.claude/skills/gstack/ and runs ./setup.
Available gstack skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /design-shotgun, /design-html, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /connect-chrome, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /setup-gbrain, /retro, /investigate, /document-release, /document-generate, /codex, /cso, /autoplan, /plan-devex-review, /devex-review, /careful, /freeze, /guard, /unfreeze, /gstack-upgrade, /learn.
Build & Development Commands
npm run dev # Start Vite dev server on port 3000
npm run build # Production build
npm run preview # Serve production build locallyBackend: Supabase project must be running. Edge Functions are deployed via supabase functions deploy. Database schema is managed through migrations in supabase/migrations/.
Architecture Overview
OpenHR is a React 19 + TypeScript HR management system using Supabase as the backend. It runs as a PWA on web (installable on desktop, iOS, and Android via the browser).
Key characteristics:
- No React Router — Uses local state routing in
App.tsxviacurrentPathstate - Context + Event Bus for state management (no Redux)
- Service layer facade — All API calls go through
hrServicewhich aggregates domain services - Multi-tenant — Every query includes
org_idfiltering viaapiClient.getOrganizationId() - PWA-enabled with service worker support, install-to-homescreen on iOS/Android, and offline caching
Data Flow Pattern
Pages/Components → Hooks → hrService (facade) → Domain Services → apiClient → Supabase SDK (via `src/services/supabase.ts`)Role-Based Access Control
Roles: SUPER_ADMIN, ADMIN, HR, MANAGER, TEAM_LEAD, EMPLOYEE
- Sidebar menu items filtered by
role.rolesarray inSidebar.tsx - Dashboard dispatches to role-specific components (AdminDashboard, ManagerDashboard, EmployeeDashboard)
- Services filter data by
organization_idfor multi-org isolation - SUPER_ADMIN bypasses all subscription checks
Role Visibility for Data
| Data | ADMIN/HR | MANAGER/TEAM_LEAD | EMPLOYEE |
| Employees | All in org | Direct reports + team | Team peers only |
| Attendance | All in org | Team members | Own only |
| Leaves | All in org | Team + own | Own only |
| Reviews | All in org | Direct reports + own | Own only |
Service Layer — COMPLETE REFERENCE
Service Facade
hrService.ts re-exports ALL methods from domain services as a single unified interface. Always use hrService from components/hooks, never import domain services directly (except employeeService.applyForLeave and apiClient).
Key Business Logic
Leave Workflow Routing (leave.service.ts):
- Employee submits leave
- System checks department workflow config (
organizationService.getWorkflows()) - If workflow
approverRole= HR/ADMIN → status =PENDING_HR(skip manager) - If employee has no
lineManagerId("Reports To" on the employee form; it can't be themselves) → status =PENDING_HR - Otherwise → status =
PENDING_MANAGER - Manager approves → status changes to
PENDING_HR - HR/Admin approves → status =
APPROVED(final). Nobody decides their own leave: another active HR/Admin must act, unless they are the organization's only one (migration 0053,src/utils/leaveApprovers.ts). The database records the decider indecided_by,decided_by_nameanddecided_at(migration 0054); clients never write these - Leave balance = quota[type] - sum(approved_days[type])
Attendance Auto-Close (attendance.service.ts):
- On
getActiveAttendance(), checks for open sessions (no check_out) - Past-date sessions: auto-closes with
autoSessionCloseTime+ remark - Same-day expired: auto-closes if
currentTime >= autoSessionCloseTime - Sends ATTENDANCE notification on auto-close
Shift Resolution (shift.service.ts):
- Check overrides for active date range
- Use employee's assigned shift (
shiftId) - Use organization default shift
- Return null
Performance Review Lifecycle (review.service.ts):
DRAFT→SELF_REVIEW_SUBMITTED(employee) →MANAGER_REVIEWED(manager) →COMPLETED(HR)- Auto-calculates attendance + leave summaries from cycle period
- Supports both JSON fields and legacy individual competency columns
Caching (organization.service.ts):
- Caches: config, departments, designations, holidays, leavePolicy, reviewConfig, leaveTypes, notificationConfig
prefetchMetadata()called on login for performanceclearCache()called on logout
Image Handling:
- All images auto-converted to WebP via
convertToWebP()utility - Applies to: avatars, selfies, blog covers, tutorial covers, showcase logos, upgrade screenshots
apiClient.toFormData()handles data URL → WebP Blob conversion
Subscription System
Statuses: TRIAL, ACTIVE, EXPIRED, SUSPENDED, AD_SUPPORTED
| Status | Access | UI |
| TRIAL | Full access | Countdown banner |
| ACTIVE | Full access | No restrictions |
| EXPIRED | Read-only | Upgrade prompt, write actions blocked |
| SUSPENDED | Complete lockout | SuspendedPage, cannot login |
| AD_SUPPORTED | Full access | Ad banners shown |
Key files:
src/context/SubscriptionContext.tsx— State,canPerformAction(), 2-min refreshsrc/components/subscription/— SubscriptionGuard, SubscriptionBanner, SuspendedPagesupabase/functions/cron-expire-trials/— Auto-expiration + trial reminders (7d, 3d, 1d)supabase/functions/—/api/openhr/subscription-statusendpoint
Camera & Geolocation — Web APIs
The app is PWA-only. All native-feature hooks use standard browser APIs:
src/hooks/attendance/useCamera.ts—navigator.mediaDevices.getUserMedia()for live stream;<input type="file" accept="image/*" capture="user">fallback for iOS PWA / blocked stream. WebP output viaconvertToWebP().src/hooks/attendance/useGeoLocation.ts—navigator.geolocation.getCurrentPosition()/watchPosition()with high-accuracy → network fallback, plus OpenStreetMap Nominatim reverse geocoding.
Rules:
- ALL native-feature components MUST have an
<ErrorBoundary>wrapper - Always handle permission-denied / no-geolocation errors with readable messages
- Location is recorded, not enforced. The org setting
allowCheckInWithoutLocation(on unlessfalse) controls check-in without a location. After any location failure, the employee taps the option, which writes a remark they can edit. That remark does not count as the mandatory factory details. A selfie is always required. These records havelocation = 'Not captured'and a[NO LOCATION: <failure>]remark tag, plus a[DIAG: ...]tag fromsrc/utils/locationDiagnostics.ts. Check-out does not use location - Test camera + location on real iOS Safari and Android Chrome before shipping (PWA standalone mode is stricter than the browser tab)
PWA Requirements
manifest.json: name, short_name, icons (192px + 512px), theme_color, background_color, display: standalone- Service worker via
vite-plugin-pwa+ Workbox - Lighthouse PWA score must be > 90
Code Standards — MUST FOLLOW
- One responsibility per component
- All native feature components must have
<ErrorBoundary>wrapper - Use custom hooks for camera and location — never call plugins directly
- All user-facing errors must show readable messages, never raw JS errors
- All images must be auto-converted to WebP before upload
- Never delete or modify existing notification/email logic without explicit approval
- Always include
organization_idin new records for multi-tenant isolation - snake_case for database fields, camelCase for TypeScript properties
- Services handle the conversion between the two naming conventions
Git Workflow — MUST FOLLOW
After completing any code changes:
- Stage the changed files:
git add <specific files>(never usegit add .orgit add -A) - Commit with a descriptive message:
git commit -m "description of changes" - Push to the current branch:
git push origin <current-branch>
Always push immediately after committing. Never leave unpushed commits.
Pre-Commit Checklist
- Camera and location tested on real iOS Safari + Android Chrome (and PWA standalone) — not just desktop
- Permission-denied UI shows readable messages
- Lighthouse PWA score > 90
- No hardcoded credentials, API keys, or Supabase URLs
- All notification hooks intact (leave, attendance, review)
- Edge Functions deployed via
supabase functions deploy
Debugging
# Test camera/location on a phone against the dev server:
# 1. Start dev: npm run dev (Vite serves on port 3000)
# 2. Expose via HTTPS tunnel (ngrok / cloudflared / Vite + cert)
# 3. Open the tunnel URL on the phone — getUserMedia / geolocation
# require HTTPS (or localhost) to work.
# Check Supabase Edge Function logs
# Use: supabase functions logs --project-ref <ref>Frozen Modules — Change-Control MUST FOLLOW
Two features — login-session stability and the attendance check-in/out lifecycle — have regressed three times during unrelated refactors. The logic that owns those features is now isolated into dedicated, single- responsibility modules. Every edit to any file in this list is a FROZEN change and requires ALL of the following, no exceptions:
- Enter plan mode first (
EnterPlanMode). No direct edits. - Get explicit user approval of the plan before executing.
- State in the plan which frozen file is being touched and why.
- Add or update a regression check — unit test when the test framework lands, or a documented manual verification in the commit message until then.
- Update
src/data/changelog.tswith afixorchangeentry. - Never bypass hooks or skip validation on the commit
(
--no-verifyis forbidden).
Frozen files
src/services/session/sessionManager.tssrc/services/session/sessionManager.types.tssrc/services/workday/workdaySessionManager.tssrc/services/workday/workdaySessionManager.types.tssrc/context/AuthContext.tsx— delegation layer only, do not move session logic back into it
Invariants (a violation is a bug)
- Only
sessionManager.tsmay callsupabase.auth.signOut(). The one tolerated exception isauth.service.ts: the post-login unverified-account clear (which runs before the user is considered logged in). Every other call site is a regression and must route throughsessionManager.forceLogout(reason). - A transient network error MUST NOT log users out. The retry +
classification logic in
sessionManager.tsis load-bearing; do not replace it with a single-shot refresh. - Only
workdaySessionManager.tsmay mutatecheck_outfrom the client as a "system auto-close". User-initiated check-outs go throughattendanceService.updateAttendance(unchanged). The remark appended for client fallback closures is" [System: Auto-closed — no check-out recorded]"— keep it distinguishable from the server cron remark (" [System: Auto-Closed Past Date]"/" [System: Max Time Reached]"). getActiveAttendanceMUST delegate toworkdaySessionManager.reconcileOpenSessions— do not add a parallel implementation that reads attendance and decides closure rules.- The
cron-auto-close-sessionsEdge Function MUST be deployed and the pg_cron schedule that invokes it MUST remain active. This is the server-side counterpart to the client-side fallback inworkdaySessionManager.ts. workdaySessionManagerMUST NOT close today's session. Same-day max-time closure is owned by the server cron; a client-side same-day close would race the cron and double-close.
Deployment checklist for session/attendance changes
Before shipping any change touching frozen files:
- Manually verified: login does NOT log out on flaky network — set DevTools → Network → Offline for ~60 s, return to Online, session must survive; a "Reconnecting…" UI banner is acceptable but a redirect to login is a regression.
- Manually verified: hard 401 DOES log the user out (invalidate the token server-side or force a password change mid-session).
- Manually verified: create an attendance record dated yesterday with
empty
check_outfor a test employee. Log in as that employee. The record must be updated withcheck_outpopulated and remarks appended; a one-time toast must appear. The UI must NOT show an "active session" card for yesterday. - Confirmed
cron-auto-close-sessionsEdge Function is deployed and the function log shows successful runs on the expected cadence. - Commit message documents which frozen file was touched and the manual verification performed.
Past incidents to learn from
- Incident 1 & 2 (see
src/data/changelog.ts2026-04-13): auto-logout after 1–2 days; PWA service-worker update caused logouts. Both were caused by refactors that did not preserve the token-refresh contract. - Incident 3 (this change, 2026-04-18): forgotten check-outs stayed
"active" because client-side auto-close was removed and the server
cron couldn't be guaranteed deployed. Fixed by isolating the lifecycle
into
workdaySessionManager.tswith a client-side fallback.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

