AI Agents Guide
AI Agents Guide
This page summarises the engineering rules every AI agent (Claude, Cursor, Copilot, Amazon Q, etc.) must follow when contributing to Global Watch. It is a public summary of the canonical sources:
- 📖
/AGENTS.md— v3.0.0, mandatory entry point - 📖
/docs/RITO_METHODOLOGY.md— v2.0.0, full engineering charter - 📖
/.kiro/steering/— 38 canonical rule files
When in doubt, the in-repo files win.
Agents who skip the investigation step (Law 1) or commit without explicit user request (Law 4) will have their work rejected. These are not suggestions.
Quick Start
Before doing anything in the repository:
- Read
/AGENTS.mdend to end (~5 min). - Read the per-workspace
AGENTS.mdfor the area you'll touch (e.g.apps/web/AGENTS.md,packages/gw/AGENTS.md). - Investigate before designing or coding (Law 1).
- Write a failing test first (Law 2).
- Place all new code in
@gw/*(Law 8). - Never commit unless the user asks (Law 4).
The 8 Absolute Laws
These rules have zero tolerance. Any violation blocks the PR.
Law 1 — Investigate Before You Build
Before designing or coding anything, search the codebase exhaustively and prove the thing does not already exist.
Required search order: packages/gw/ → packages/fw/ → apps/{web,map,mobile}/ → .kiro/specs/ → .kiro/steering/.
The investigation must be documented in your plan as an Investigation Report.
Law 2 — TDD Iron Law
RED → GREEN → REFACTOR. Always in that order. No production code before a failing test that fails for the right reason.
# 1. RED: write a failing test
pnpm --filter <pkg> test:run # must FAIL
# 2. GREEN: minimal code to pass
pnpm --filter <pkg> test:run # must PASS
# 3. REFACTOR: clean up
pnpm --filter <pkg> test:run # must STAY PASSCoverage floor: 70% overall, 90% on critical paths (auth, billing, RLS, multi-tenancy).
Law 3 — Type Safety Is Not Optional
any, as any, @ts-ignore, @ts-expect-error in production code = rejection.
// ❌ REJECTED
const data: any = getData();
// ✅ Library types
import type { GeoJSONSource } from 'mapbox-gl';
const source = map.getSource('points') as GeoJSONSource;
// ✅ Database types (source of truth for DB shape)
import type { Database } from '~/lib/database.types';
type ProjectRow = Database['public']['Tables']['projects']['Row'];
// ✅ unknown + type guards
function process(data: unknown) {
if (typeof data === 'object' && data !== null) { /* ... */ }
}Law 4 — Commit Only When Asked
No git commit without explicit user request. This includes git push, --amend, rebase, and git add of unrelated files.
Stage changes. Propose a Conventional Commit message. Wait for the user to say "commit."
Law 5 — Workspace Boundaries Are Sacred
Working in apps/web/? Stay in apps/web/. Working in packages/gw/{name}/? Stay there.
Reading other workspaces for investigation (Law 1) is always allowed. Cross-cutting changes (root package.json, turbo.json, shared configs) require explicit approval.
Law 6 — Environment Variables for All URLs
// ❌ REJECTED
const url = 'http://localhost:3000/auth/callback';
const origin = window.location.origin;
// ✅ CORRECT
const url = process.env.NEXT_PUBLIC_APP_URL + '/auth/callback';Required env vars: NEXT_PUBLIC_APP_URL, NEXT_PUBLIC_BASE_DOMAIN, NEXT_PUBLIC_SITE_URL.
Law 7 — Post-Task Review Is Mandatory
pnpm typecheck # exit 0
pnpm lint:fix # exit 0
pnpm format:fix # no diff (or commit it)
pnpm --filter <pkg> test:run # all green
pnpm --filter <app> build # exit 0 (when applicable)For UI work, re-read your own JSX for nesting, accessibility, and i18n keys.
Law 8 — All New Code Lives in @gw/*
| Namespace | Status | What goes here |
|---|---|---|
@gw/* (packages/gw/) | 🟢 Active — present and future | All new code, components, services, packages. |
@fw/* (packages/fw/) | 🟡 Frozen — patches only | Existing legacy code. Critical bug fixes only. No new files. |
@kit/* (packages/) | 🔴 Archaeology — read-only | Original Makerkit boilerplate. Reference only. |
When extending or replacing functionality from @kit/* or @fw/*, build the new version in @gw/* and migrate consumers progressively.
RITO Methodology v2.0.0
RITO = Rigor · Iteration · Testing · Ownership.
The RITO Loop is the only sanctioned development cycle:
Intent → (Spec) → Investigation → TDD (RED) → Build (GREEN/REFACTOR) → Review → Docs → ShipInvestigation Protocol
Use these tools — in parallel when possible:
| Tool | Purpose |
|---|---|
grep / ripgrep | Text search across the entire repo |
ast_grep | Structural code search (functions, components) |
glob | Find files by name pattern |
lsp_* (find_references, goto_definition, symbols) | Symbol-aware navigation |
explore agent | Parallel multi-angle codebase grep |
librarian agent | External docs / OSS reference search |
Investigation Report (required in your plan)
## Investigation Report
**Task:** <one sentence>
**Searched:**
- packages/gw/ → grep "<term>" → <findings or "no matches">
- packages/fw/ → grep "<term>" → <findings or "no matches">
- apps/web/ → grep "<term>" → <findings or "no matches">
- .kiro/specs/ → ls + grep → <relevant specs or "none">
- .kiro/steering → relevant files → <list>
**What already exists that I will reuse:**
- <file:line> — <what it provides>
**What does not exist and must be created:**
- <component/service/page> in `packages/gw/<name>/` because <reason>
**Decision:**
- Reuse: <list>
- Create new in @gw: <list>
- Migrate from @fw if encountered: <list>No report = no work.
Definition of Done
A task is complete only when every box is checked:
[ ] Investigation Report included in the plan (Law 1)
[ ] Failing test was written first (Law 2)
[ ] Implementation makes the test pass
[ ] All new code is in @gw/* or app workspaces (Law 8)
[ ] No new files in @fw/* or @kit/* (Law 8)
[ ] pnpm typecheck → exit 0
[ ] pnpm lint:fix → exit 0
[ ] pnpm format:fix → no uncommitted diff
[ ] pnpm --filter <pkg> test:run → all green
[ ] pnpm --filter <app> build → exit 0 (if app code changed)
[ ] Feature manually verified in browser → no console errors
[ ] No regressions in adjacent features
[ ] i18n keys present in en, pt-br, ar → if UI strings added
[ ] RTL verified → if UI changed
[ ] RLS policy added/updated and tested → if DB tables touched
[ ] docs/features/{FEATURE}.md updated → §Documentation Contract
[ ] apps/docs MDX updated → if user-facing
[ ] ADR written → if architectural decision made
[ ] Commit message proposed (NOT executed) → Law 4Documentation Contract
For every shipped feature, produce two artifacts (and optionally a third):
| Artifact | Path | Audience |
|---|---|---|
| Internal feature doc | docs/features/{FEATURE_NAME}.md | Engineering team |
| Public MDX | apps/docs/content/docs/{section}/{feature}.mdx | Customers / integrators |
| ADR (optional) | docs/architecture/ADR-{NNN}-{slug}.md | Future contributors — only when an architectural decision was made |
Sprint documents (SPRINT_N_*.md) are no longer required. Time/cost tracking is not part of the documentation contract.
Commit Message Format
Conventional Commits. No time tracking. Wait for explicit user request before running git commit.
type(scope): brief description
[Optional body explaining the why]
✅ Verified:
- TypeCheck: ✅
- Lint: ✅
- Tests: ✅ <X/Y passing>
- Build: ✅
- Manual: ✅
📚 Documentation:
- docs/features/{FEATURE}.md
- apps/docs/content/docs/{section}/{feature}.mdx (if user-facing)
- docs/architecture/ADR-NNN-{slug}.md (if architectural decision)
Closes #XXXTypes: feat, fix, chore, refactor, docs, test, style, perf, build, ci.
Feature Flags
Verify flag state before implementing — building for a disabled flag is wasted work.
| Flag | Default | Description |
|---|---|---|
enableThemeToggle | ✅ true | Light/dark theme toggle |
enableTeamAccounts | ✅ true | Team accounts |
enableTeamCreation | ✅ true | Team creation |
enableNotifications | ✅ true | Notification system |
enableWorkOrders | ✅ true | Work orders & crews |
enableAccountDeletion | ❌ false | Personal account deletion |
enableTeamDeletion | ❌ false | Team deletion |
enablePersonalAccountBilling | ❌ false | Personal billing |
enableTeamAccountBilling | ❌ false | Team billing |
realtimeNotifications | ❌ false | Realtime notifications |
Source of truth: apps/web/config/feature-flags.config.ts.
Rules: never enable billing/deletion flags without explicit authorization. Document any feature that depends on a specific flag.
Optional: Context Manager Tooling
The repo ships an optional Context Manager (@fw/context-manager) that can persist and switch between workstreams when several agents collaborate. It is not mandatory under RITO v2.0.0 — your task list (todowrite) and the per-task Investigation Report cover the required state.
# Track lifecycle (optional)
pnpm track:list
pnpm track:create my-track "Agent name" "What this track is for"
pnpm track:switch my-track
pnpm context:restart
# Save / load context
pnpm context:save
pnpm context:loadGetting Help
When stuck:
- Re-read
/AGENTS.md. - Consult
/docs/RITO_METHODOLOGY.md. - Consult the relevant file in
/.kiro/steering/. - Ask the user before proceeding.
Never improvise. Always ask when in doubt.
Related Documentation
- Development Setup — environment configuration
- Coding Conventions — code standards
- Testing Overview — testing strategies
- Architecture — system design