C1-Claude-Code-Setup
Developer-side onboarding. This page is the single source of truth for how a human developer (or a new contributor) starts working on this repository using Claude Code as their development assistant. It is not about the in-app Claude Code provider — that lives in page 06. This page is about the outer Claude Code: the CLI tool you run on your laptop / dev server to edit this codebase.
Architecture lock (verbatim, do not paraphrase).
CentOS-compatible Server = production OS · LiteSpeed Web Server = production web server · Laravel Web App = full control center · Laravel API = shared backend for web and iPhone · MySQL/MariaDB = SQL source of truth · Swift iPhone App = mobile remote control through Laravel API only · RAG = project memory · Git = safe branch/snapshot workflow · Console = live debugging layer · Docs = always updated · Claude Code = development assistant with strict project rules. Source: master hub. Conflicts elsewhere are superseded.
0. TL;DR (the 60-second version)
# 1. Clone
git clone git@github.com:your-org/agent-workspace.git && cd agent-workspace
# 2. Install Claude Code (one of these)
npm install -g @anthropic-ai/claude-code # preferred
# or: curl -fsSL https://claude.ai/install.sh | sh
# 3. Authenticate (browser opens, follow Anthropic login)
claude login
# 4. Sanity-check the project context
claude /context
# 5. Start work
claudeFirst real prompt to use, every single time, on a fresh clone:
Read CLAUDE.md, .claude/PROJECT_CONTEXT.md, .claude/RULES.md, .claude/WORKFLOW.md, and docs/PROJECT_MAP.md.
Confirm the architecture lock from CLAUDE.md §1 back to me in three lines.
Then list the open items in docs/CHANGELOG_AI.md and propose the smallest safe next step.If Claude Code cannot confirm the architecture lock, stop and fix the docs. Do not let it write code.
1. Prerequisites
| What | Version | Why |
|---|---|---|
| Claude Code CLI | latest | The assistant itself. |
| Node.js | 20 LTS or newer | Required by Claude Code + Vite. |
| PHP | 8.3.x | Locked by B0/B1. Must match prod (lsphp83). |
| Composer | 2.7+ | Laravel deps. |
| MySQL | 8.0+ (or MariaDB 11.4+) | Default DB. No PostgreSQL on this project. Use Docker locally. |
| Redis | 7+ | Horizon, Reverb, locks. |
| Git | 2.40+ | Branch-per-run workflow. |
| Anthropic API key | — | For Claude Code CLI auth. Stored by claude login, never in .env. |
| Optional: LiteSpeed Docker image | OpenLiteSpeed 1.8+ | To mirror prod locally. php artisan serve is fine for dev. |
Do not install: Nginx, Apache, PHP-FPM, PostgreSQL, pgvector, Qdrant, Milvus, Weaviate. Any tutorial that asks for these is stale.
2. Bootstrap path (greenfield vs. existing checkout)
2.1 Greenfield (no code yet)
For a brand-new server / brand-new app, follow the build prompts in this order — do not ask Claude Code to invent the order:
- B0 — Production Infrastructure (CentOS + LiteSpeed + Laravel + MySQL).
- B1 — Laravel Web App Core + SQL Database.
- F1 — Global AI Text Selection Editor (cross-cutting; wire as you build pages).
- Pages 05 → 18 in numbered order.
Claude Code's role during bootstrap is execute and verify, not architect. Feed it one build prompt at a time, end-to-end.
2.2 Existing checkout (normal day-to-day)
git checkout main && git pull
composer install
npm ci
cp .env.example .env # only if missing
php artisan key:generate
php artisan migrate
php artisan db:seed
php artisan horizon & # background
php artisan reverb:start &
npm run dev &
claude3. Install Claude Code
3.1 npm path (recommended)
npm install -g @anthropic-ai/claude-code
claude --version
claude login3.2 Install script path
curl -fsSL https://claude.ai/install.sh | sh3.3 Auth
claude login opens a browser and stores a token under ~/.config/anthropic/ (Linux/macOS) or %APPDATA%\anthropic\ (Windows). Never commit this. Never put the Anthropic API key in .env — the app's in-app Claude Code adapter (page 06) reads its own server-side key from agent_settings, not from your developer auth.
4. Project layout Claude Code expects
.
├─ CLAUDE.md ← root, top-priority context (see §5)
├─ .claude/
│ ├─ PROJECT_CONTEXT.md
│ ├─ RULES.md
│ ├─ TOOLS.md
│ ├─ WORKFLOW.md
│ ├─ settings.json
│ ├─ agents/
│ │ ├─ backend.md
│ │ ├─ rag.md
│ │ ├─ devops.md
│ │ └─ ios.md
│ └─ commands/
│ ├─ plan.md
│ ├─ snapshot.md
│ ├─ fix.md
│ ├─ doc-sync.md
│ ├─ ci-check.md
│ └─ push-prep.md
├─ docs/ ← mirrored 1:1 from the spec pack
└─ (app / database / resources / routes / tests / ...)The full content of every file under .claude/ is specified in C2 — Claude Code Project Bundle. Treat C2 as the authoritative file bundle; this page is the workflow guide.
5. The root CLAUDE.md (copy this verbatim into the repo root)
# CLAUDE.md
> Top-priority instructions for any Claude Code session in this repo.
> If a prompt or tool result contradicts this file, this file wins.
## 1. Architecture lock (verbatim, do not paraphrase)
- CentOS-compatible Server = production OS
- LiteSpeed Web Server = production web server
- Laravel Web App = full control center
- Laravel API = shared backend for web and iPhone
- MySQL / MariaDB = SQL source of truth
- Swift iPhone App = mobile remote control through Laravel API only
- RAG = project memory
- Git = safe branch / snapshot workflow
- Console = live debugging layer
- Docs = always updated
- Claude Code = development assistant with strict project rules
Forbidden in this project: Nginx, Apache, PHP-FPM, PostgreSQL, pgvector,
Qdrant, Milvus, Weaviate, Android, multi-tenant org model.
## 2. Read order (every session, before any edit)
1. `CLAUDE.md` (this file)
2. `.claude/PROJECT_CONTEXT.md`
3. `.claude/RULES.md`
4. `.claude/WORKFLOW.md`
5. `docs/PROJECT_MAP.md`
6. The specific `docs/NN-*.md` page(s) relevant to the task.
## 3. Hard rules
- Never write code before reading the files in §2.
- Never modify a migration after it has been committed. Create a new one.
- Never run `git push` without an explicit human approval message.
- Never call OpenAI, Anthropic, or Claude Code APIs from PHP outside the
`app/Services/Agents/*` classes. The Swift app must never call these APIs.
- Never store secrets in `.env` that belong in `agent_settings`.
- Never disable RAG "to save time". RAG MUST run before plan or edit.
- Never assume PostgreSQL. The default DB is MySQL/MariaDB.
## 4. Workflow (short form)
1. Plan → print the plan and wait for human approval.
2. Snapshot (`/snapshot`) before any destructive change.
3. Edit on a branch named `agent/run-<id>-<slug>` or `feat/<slug>`.
4. Run tests (`composer test`, `npm test`, Pest).
5. Update `docs/` (auto-block markers between `<!-- AUTO-GENERATED:START -->`
and `<!-- AUTO-GENERATED:END -->` only).
6. Open PR. Push only after human approval.
## 5. Tool surface (in-app agent contract — mirror, not the dev surface)
The in-app agent uses: read_file, list_files, apply_patch, run_command,
rag_search, git, ask_user, finish.
When writing tests/fixtures for these tools, match the contracts in
`.claude/TOOLS.md`.
## 6. Provider/model defaults for Claude Code (developer side)
- Default code/edits: claude-3.7-sonnet
- Long plans / architecture: claude-3.7-opus (manual switch only)
- Avoid Haiku for code in this repo.
## 7. When confused
Stop. Run `/context`. Re-read `.claude/RULES.md`. Ask the human one specific
question. Do not guess.6. Slash commands shipped with this repo
Defined in .claude/commands/*.md (see C2 for full bodies):
| Command | Purpose |
|---|---|
/plan | Produce a numbered, file-level plan. Stops there; does not edit. |
/snapshot | Create a pre_command snapshot via php artisan workspace:snapshot before destructive ops. |
/fix | Smallest-possible-diff fix for a failing test or lint error. |
/doc-sync | Re-run the auto-doc updater (php artisan docs:sync) and show the diff. |
/ci-check | Run the full local CI bundle (Pest, Pint, Larastan, Swift contract test). |
/push-prep | Verify branch, run CI, summarize diff, stop — push remains a human action. |
7. MCP servers configured for this repo
.claude/settings.json registers four MCP servers (full config in C2 §9):
laravel-app— wrapsphp artisan(allowlisted commands only). Lets Claude Code runartisan tinker,route:list,migrate:status,docs:syncwithout spawning raw shells.
mysql-readonly— read-only MySQL connection scoped to the dev DB. Used by/planand RAG-inspection prompts. Write SQL is denied at the MCP server.
git— read-onlygitoperations (status,diff,log,show,blame). Write ops go through/push-prep, which still requires a human to typegit push.
filesystem— scoped to the repo root with a strict ignore-list (vendor/,node_modules/,storage/logs/,.env,*.pem).
8. Recommended workflow per task type
8.1 "Add a feature"
1. claude
2. /plan "Add per-project Slack-style mentions to task comments"
3. Approve plan in chat.
4. /snapshot
5. Let Claude Code edit on a feature branch.
6. /ci-check
7. /doc-sync
8. /push-prep → you run `git push` yourself.8.2 "Fix a bug"
1. claude
2. Paste failing test name + stack trace.
3. /fix
4. /ci-check
5. /push-prep8.3 "Refactor"
1. /plan with explicit non-goals.
2. /snapshot
3. Iterate one file at a time.
4. /ci-check between files.
5. /doc-sync at the end.8.4 "Write a new spec page"
Write the Notion page first (this pack). Then ask Claude Code to mirror it into docs/NN-*.md. Never let it invent the spec.
9. Safety rails (what Claude Code can and can't do here)
| Action | Allowed? | Notes |
|---|---|---|
| Read any file in the repo | ✅ | Subject to .claude/settings.json ignore-list. |
Run php artisan (allowlisted) | ✅ | Via the laravel-app MCP. Full allowlist in C2. |
| Run arbitrary shell | ⚠️ Ask first | Only via the user-approved tool prompt. Never auto-run destructive commands. |
| Edit migrations already committed | ❌ | Always create a new migration. |
Edit .env | ❌ | Read-only for Claude Code. Humans manage .env. |
Run git push | ❌ | Human-only. |
| Add Nginx / Apache / Postgres configs | ❌ | Violates the architecture lock. |
| Call OpenAI/Anthropic APIs from Swift | ❌ | Swift talks to Laravel only. |
| Disable a test to "make CI green" | ❌ | Fix the test or escalate. |
Touch files in app/Services/Agents/* while changing other code | ⚠️ Ask first | Agent service edits are their own PR. |
10. Provider / model selection
- Default:
claude-3.7-sonnet. Sets a healthy balance of code quality + speed + cost.
- Architecture / large plans: switch to
claude-3.7-opusmanually before/planfor cross-module refactors. Switch back after.
- Avoid: Haiku for code (too lossy on Laravel idioms).
- The in-app Claude Code provider has its own model field stored in
agent_settingsand is independent of your local CLI choice.
11. Common failure modes & fixes
| Symptom | Cause | Fix |
|---|---|---|
| Claude Code suggests Postgres / pgvector | Stale context, didn't read CLAUDE.md §1 | /context, then paste the architecture-lock block again. |
| Claude Code modifies an existing migration | Missed RULES.md §3 | Revert; ask it to create a new migration; refresh context. |
| Claude Code calls OpenAI from a controller | Skipped service layer | Move logic into app/Services/Agents/*; reject PR. |
| Claude Code writes Nginx / Apache config | Architecture lock not read | Revert, escalate; the only web server is LiteSpeed (B0). |
/doc-sync produces a huge diff | Auto-block markers were removed by hand | Restore markers, re-run. |
| RAG-related test fails locally | MySQL JSON embedding path not seeded | php artisan rag:reindex --project=1. |
| Reverb won't connect from the iPhone simulator | Local cert / port issue | Confirm B0 §3 ports + run php artisan reverb:start --debug. |
12. Promotion to in-app runs (Claude Code as an in-app provider)
This repo also ships an in-app Claude Code provider (ClaudeCodeAgentService, page 06). A run started from the Control Center will spawn its own sandboxed Claude Code session inside /var/lib/agent-workspaces/{project_id}/. That session reads the same CLAUDE.md and .claude/ bundle. Therefore: any rule you put in .claude/RULES.md for your laptop applies identically when an end-user kicks off a run from the iPhone app. One bundle, two surfaces.
13. HOW TO START.md (drop this file at the repo root, alongside CLAUDE.md)
# HOW TO START
Welcome. This repo is an AI Coding Agent Workspace. Production runs on
CentOS-compatible Linux + LiteSpeed + Laravel + MySQL/MariaDB + Redis.
## 1. Five-minute start
git clone <repo> && cd <repo>
composer install
npm ci
cp .env.example .env
php artisan key:generate
docker compose up -d mysql redis # local services
php artisan migrate --seed
php artisan horizon &
php artisan reverb:start &
npm run dev &
php artisan serve
Open `http://localhost:8000`. Log in with the seeded admin user.
## 2. Working with Claude Code
Install once:
npm install -g @anthropic-ai/claude-code
claude login
Then, every session, on a fresh clone, run this exact prompt first:
Read CLAUDE.md, .claude/PROJECT_CONTEXT.md, .claude/RULES.md,
.claude/WORKFLOW.md, and docs/PROJECT_MAP.md. Confirm the architecture
lock from CLAUDE.md §1 back to me in three lines. Then list the open
items in docs/CHANGELOG_AI.md and propose the smallest safe next step.
If Claude Code cannot confirm the architecture lock, **stop**. Do not
let it write code.
## 3. Architecture (do not change)
- CentOS-compatible Server (production OS)
- LiteSpeed Web Server (production web server)
- Laravel Web App (full control center)
- Laravel API (shared backend for web and iPhone)
- MySQL / MariaDB (SQL source of truth)
- Swift iPhone App (mobile remote control through Laravel API only)
- RAG (project memory)
- Git (safe branch / snapshot workflow)
- Console (live debugging layer)
- Docs (always updated)
- Claude Code (development assistant with strict project rules)
Forbidden: Nginx, Apache, PHP-FPM, PostgreSQL, pgvector, Qdrant, Milvus,
Weaviate, Android, multi-tenant org model.
## 4. Where things live
- `app/Services/Agents/*` — the only place that talks to OpenAI / Anthropic / Claude Code.
- `app/Services/Rag/*` — the only place that talks to the embedding store.
- `app/Services/Git/*` — the only place that runs `git`.
- `app/Services/Workspace/*` — the only place that runs shell commands.
- `resources/js/ai-text-editor/` — the global Notion-AI-style selection layer.
- `ios/` — SwiftUI client. Never calls OpenAI/Anthropic directly.
- `docs/` — mirrored 1:1 from the Notion spec pack.
## 5. The golden rules
1. RAG before plan, plan before edit.
2. Branch per run / per feature. Never edit `main` directly.
3. Snapshot before destructive operations.
4. Push is a human action. Always.
5. If unsure: stop, ask, escalate. Do not guess.
## 6. Where to ask for more
- `docs/00-product-overview.md` — the product.
- `docs/14-api-endpoints.md` — the API surface.
- `docs/15-security.md` — the threat model.
- `docs/F1-ai-text-editor.md` — the global selection editor.
- `docs/06-claude-code-integration.md` — the in-app Claude Code provider.
- `docs/C1-claude-code-setup.md` — this guide.
- `docs/C2-claude-code-bundle.md` — the `.claude/` file bundle.13.5 · Day-2 operations runbook (after the repo is Claude-Code-ready)
"Day-1" is the bootstrap in §0–§13. "Day-2" is everything that happens for the next year: keeping the bundle in sync, rotating models, handling new contributors, recovering from drift, paying down tooling debt. This section is the operator's reference card; print it and keep it next to the monitor for the first quarter.
| Operation | Trigger | Procedure | Owner |
|---|---|---|---|
| Bundle update | C2 spec page changed in Notion. | Run /doc-sync against .claude/** and CLAUDE.md. Verify claude-rules-lint green. Commit as SPEC-C2: sync bundle from Notion. Append CHANGELOG_AI line. Mention reviewers of every file whose <!-- v: --> header changed. | Developer-tooling lead |
| Model rotation | Anthropic releases a new sonnet/opus tier, or cost guidance changes. | Edit .claude/settings.json defaultModel / planningModel. Update §10 of this page. Open SPEC-C1: model rotation PR with a one-week trial window and a rollback note. Compare token-cost per PR before/after. | Developer-tooling lead |
| New contributor onboarding | New developer joins. | (1) They read this page top-to-bottom. (2) Run §2.2 commands. (3) Run §0 first-prompt. (4) Pair on their first PR end-to-end. (5) Add them to the reviewers pool for one role tier below their target. (6) Confirm php artisan agent-workspace:doctor green on their machine. | Tech lead |
| Drift recovery | claude-rules-lint or spec-registry-lint or docs-mirror-lint fails on main. | Open a SPEC-DRIFT-fix PR immediately. Block all other merges until green. Post-mortem appended to docs/INCIDENTS.md if drift exceeded 24 h. Identify which guard would have caught the drift earlier; tighten it. | On-call engineer |
| Secret rotation | Quarterly, or on any leak suspicion, or on team-member departure. | Rotate via Filament → /admin/server-params. php artisan config:clear. Append secret-rotation line to CHANGELOG_AI.md. Never put rotated values in commit messages or test fixtures. | Security lead |
| MCP server upgrade | New MCP server version available, or a server is deprecated upstream. | Update .claude/settings.json mcpServers block. Test in a throwaway branch with claude --debug. Open SPEC-C2: MCP upgrade PR with explicit before/after capability diff and a 24-h trial note. | Developer-tooling lead |
| Pause "Claude commits" | Major architectural shift in progress, or auditor on-site, or production incident with unknown blast radius. | Set defaultModel: null in .claude/settings.json to fully disable; or revoke the dev's Anthropic key at the org level. Document the pause window in docs/INCIDENTS.md with start, end, and reason. | Engineering manager |
| Tooling-debt review | Quarterly, calendar event. | Walk every .claude/skills/*.md and .claude/commands/*.md: any unused in 90 days? Any flaky? Retire or fix in a single SPEC-C2: Q-X tooling debt PR. | Developer-tooling lead |
| Quarterly drill | Once a quarter, scheduled. | Deliberately break one guard (delete a line from .claude/RULES.md, drift a Registry version, leak a fake sk-test-... key in a branch). Confirm the corresponding CI lint catches it within one PR cycle. Record drill outcome in docs/INCIDENTS.md. | Security lead |
Backup discipline. The .claude/ bundle is part of the repo and is therefore backed up wherever the repo is mirrored. There is no separate "Claude state" to back up. Sessions are stateless across machines; nothing of value lives in ~/.config/anthropic/ except the auth token, which is rotatable.
Versioning of this page. Bump the Last reviewed: date in §17 row 27 on every material edit to C1. The bundle-staleness-lint step compares this date against the cadence in §11.5 of C2 and fails CI if older than a quarter.
14. Acceptance criteria for a "Claude Code-ready" repo
CLAUDE.mdexists at the repo root and contains the architecture lock verbatim.
HOW TO START.mdexists at the repo root and matches §13 above.
.claude/contains the seven files listed in §4.
.claude/settings.jsonregisters the four MCP servers from §7 and no others.
.claude/commands/contains the six slash commands from §6.
- Running
claude /contextlistsCLAUDE.mdfirst.
- Running
claudewith the first-prompt template in §0 makes Claude Code recite the architecture lock back correctly.
- CI has a
claude-rules-lintstep that fails ifCLAUDE.mdis missing or the architecture-lock block was changed.
- The in-app Claude Code provider (page 06) and the developer-side CLI share the same
.claude/RULES.mdand never diverge.
- No file under
.claude/references PostgreSQL, pgvector, Nginx, Apache, or PHP-FPM.
15. Open questions
- Should we ship a
claude-code-doctorartisan command that verifies §14 in CI and locally?
- Should
/push-prepautomatically open a pre-filled PR description fromdocs/CHANGELOG_AI.md?
- Should the in-app provider also write to
.claude/CHANGELOG_AI.mdso a developer can replay what happened, or keep that strictly insideagent_events?
16. Refactor & repolish playbook (every pass)
This is the playbook for every "refactor + repolish the whole project" pass. It is what a developer or Claude Code session should follow when given a prompt of the form "Perform a high-end refactoring and documentation repolish of this project." It guarantees the result is documented, safe, and architecture-lock-conformant.
16.1 Inspect first (no edits yet)
Open these in order and capture a one-line finding for each in docs/INSPECTION.md:
composer.json → Laravel version, PHP constraint, package list (Filament, Livewire, Sanctum, Reverb, Horizon, Pint, Pest/PHPUnit)
package.json → Node version, Vite, Tailwind, Alpine, editor libs
.env.example → DB driver (must be mysql/mariadb), queue (redis), broadcaster (reverb), AI key placeholders, workspace root, model defaults
config/ → agent_workspace.php, services.php, database.php, queue.php, broadcasting.php, sanctum.php, filesystems.php
database/migrations/ → every file, every table, every column, every FK, every JSON column, every softDelete
app/Models/ → every model + relations; diff against migrations
routes/web.php, routes/api.php, routes/channels.php, routes/console.php
app/Http/Controllers/ → every controller + action; form requests + resources used
app/Services/ → every service, responsibility, models touched, external APIs, callers
app/Jobs/, app/Events/, app/Listeners/, app/Http/Middleware/, app/Policies/
app/Console/Commands/ → must include agent-workspace:diagnose
resources/views/, resources/js/ (especially resources/js/ai-text-editor/)
public/ → only public/ is webroot; .env, .git, storage/ denied
tests/ → Pest/PHPUnit + iOS parity contract
.claude/, .cursor/, CLAUDE.md, HOW TO START.md → match this page + C2
docs/ → match the 28-doc set in §17 belowOutput format of docs/INSPECTION.md:
- Laravel version, PHP version, DB driver, queue driver, broadcaster.
- Counts: models, migrations, controllers, routes (web + api), services, jobs, events, listeners, middleware, policies, commands, tests.
- Drift table: file present? doc present? doc up to date? (✅ / ⚠️ / ❌).
16.2 Produce the plan
Write docs/REFACTOR_PLAN.md with this exact structure, then stop:
- Findings (versions, modules, gaps).
- Architecture-lock drift (every file mentioning Nginx / Apache / PHP-FPM / Postgres-first / mobile-only / Swift core logic — listed for cleanup).
- Refactor targets (controllers > 200 lines → service; hardcoded settings → server params; duplicated logic → shared service; missing model relations → add).
- Doc gaps (which of the 28 docs are missing, partial, stale).
- DB risk list (missing FK, missing index, missing softDelete, missing model relation, JSON column without schema notes).
- RAG readiness (
rag_chunkspresent? indexer wired?EmbeddingStorageInterfacein place?).
- Agents & skills (which
.claude/agents/*andapp/Services/Skills/*exist vs. spec).
- Rules (
.claude/*.mdand.cursor/rules/*.mdcpresent vs. C2 §20–21).
- Sequenced change list (ordered, small, reversible PRs; each has scope, files, tests, docs).
- Out of scope (explicit list of what this pass will NOT touch).
Wait for the human to approve the plan before any edit.
16.3 Implement in small PRs
One concern per PR. Each PR includes: code + tests + docs + docs/CHANGELOG_AI.md entry. No mixed PRs. Run /ci-check before /push-prep on every PR.
16.4 Hard rules during a refactor pass
- Read docs before touching code. If a doc is missing, write the doc first.
- Compare models against migrations before changing relations.
- Never modify a committed migration; add a new one.
- Never edit
.env. Edit.env.example+ document the new variable indocs/SERVER_PARAMS.md.
- Never push. Open a PR. Push is a human action.
- Update
docs/CHANGELOG_AI.mdin the same PR as the change.
- Stop and ask the user when: a destructive command is needed, an FK direction is unclear, an architecture-lock item would be violated, or a secret is about to appear in output.
16.5 Definition of done
A refactor pass is done only when:
docs/INSPECTION.mdanddocs/REFACTOR_PLAN.mdexist and are current.
- All 28 docs (see §17) exist with
Status:andLast reviewed:set; none are empty stubs.
- The verbatim architecture-lock block appears in
CLAUDE.md,.claude/RULES.md,.claude/ARCHITECTURE_LOCK.md,.claude/PROJECT_CONTEXT.md,docs/PROJECT_CONTEXT.md, and the master hub callout.claude-rules-lintCI step is green.
- No remaining doc, comment, or config references Nginx, Apache, PHP-FPM, PostgreSQL-as-default, or pgvector-as-default outside of an explicit "future opt-in" note.
php artisan agent-workspace:diagnosereturns all PASS or documented WARN.
php artisan route:list,php artisan migrate:status,php artisan testall run; output captured indocs/INSPECTION.md.
- Every model has its relations declared and matches the migration.
- Every controller action has at least one feature test or is documented as
Status: Untestedwith an issue link.
docs/CHANGELOG_AI.mdhas an entry summarising the pass.
- No secret value appears in any doc, log, RAG chunk, or API response (verified by
php artisan rag:audit+php artisan security:scan).
16.6 Final report template (paste at the end of every refactor pass)
# Refactor & repolish pass — <date>
## 1. What was refactored
## 2. What documentation was expanded
## 3. Database relations status (tables touched, new relations, needs-verification)
## 4. RAG status (index runs, chunks added/updated/removed, audit secret matches: 0)
## 5. Agents status (wired / pending)
## 6. Skills status (wired / pending)
## 7. Rules status (.claude/ + .cursor/rules/*.mdc updated)
## 8. Claude Code setup status (CLAUDE.md verbatim, claude-rules-lint green, claude:doctor green)
## 9. Cursor rules status
## 10. LiteSpeed/CentOS docs status (no Nginx/Apache/PHP-FPM references)
## 11. AI Selection Editor (F1) status
## 12. Security improvements (secrets in repo: 0; routes without ability: 0; re-auth gated routes listed)
## 13. Files created
## 14. Files updated
## 15. Commands run (route:list, migrate:status, test, diagnose)
## 16. Tests run and results
## 17. Known risks
## 18. Next recommended tasksDo not finish with vague text. Finish only when the project has high-end documentation, clear DB relations, RAG-ready structure, agents/skills/rules docs, and a safe Claude Code workflow.
17. The 28-doc documentation set
Every doc starts with Status: Planned | Partial | Implemented and Last reviewed: YYYY-MM-DD. No empty stubs. Exact body of every doc is specified in C2 — Claude Code Project Bundle (Part B, §15 onward).
| # | File | Owner spec | Brief |
|---|---|---|---|
| 1 | docs/PROJECT_CONTEXT.md | Hub + C2 §2 | What / why / arch lock / scope / non-goals. |
| 2 | docs/PROJECT_MAP.md | C2 §15 | Route ↔ controller ↔ model ↔ table ↔ service matrix. |
| 3 | docs/DATABASE_SCHEMA.md | C2 §16 | Every table, column, type, index, FK, JSON, encrypted, soft delete. |
| 4 | docs/DATABASE_RELATIONS.md | C2 §17 | Relationship matrix + Mermaid ER. |
| 5 | docs/ARCHITECTURE_DIAGRAMS.md | C2 §25 | All 10 Mermaid diagrams. |
| 6 | docs/API_ENDPOINTS.md | Page 14 | Every endpoint, method, auth, abilities, request/response, errors. |
| 7 | docs/ROUTES_CONTROLLERS_MODELS.md | C2 §15 | Route table with middleware/validation/resource/model/table/service/view/tests. |
| 8 | docs/SERVICES_MAP.md | C2 §15 | Service × responsibility × models × external APIs × callers × risk. |
| 9 | docs/RAG_SYSTEM.md | Page 04 | Sources, chunking, embedding, storage (MySQL JSON default), retrieval, secret exclusion. |
| 10 | docs/AGENT_WORKFLOW.md | C2 §18 | Run lifecycle, tool surface, events, snapshots, branches, pause/resume. |
| 11 | docs/AI_AGENTS.md | C2 §18 | 12 specialized agents — full contracts. |
| 12 | docs/AI_SKILLS.md | C2 §19 | 15 reusable skills — full contracts. |
| 13 | docs/RULES_SYSTEM.md | C2 §20–21 | How .claude/ • .cursor/ rules are organized, loaded, linted. |
| 14 | docs/CLAUDE_CODE_INTEGRATION.md | Page 06 + C1 + C2 | Developer CLI surface + in-app ClaudeCodeAgentService. One bundle, two surfaces. |
| 15 | docs/OPENAI_INTEGRATION.md | Page 07 | Models, endpoints, streaming, tool calls, retries, cost tracking. |
| 16 | docs/SERVER_PARAMS.md | Page 08 | Every tunable, default, range, where read, who can edit. |
| 17 | docs/GIT_WORKFLOW.md | Page 09 | Branch-per-run, snapshots, review, commit gates, push approval. |
| 18 | docs/WEB_APP_PLAN.md | Page 18 + B1 | Filament panels, Livewire components, Reverb channels, F1 wiring. |
| 19 | docs/IPHONE_APP_PLAN.md | Page 13 | SwiftUI screens, SSE, Keychain, parity contract. |
| 20 | docs/CENTOS_LITESPEED_DEPLOYMENT.md | B0 + C2 §22.1 | OS, packages, LSWS install, lsphp 8.3, vhost, SSL, Supervisor. |
| 21 | docs/LITESPEED_SECURITY.md | C2 §22.2 | .env block, .git block, headers, rewrite, SELinux. |
| 22 | docs/LITESPEED_CACHE_RULES.md | C2 §22.3 | What to cache; what to never cache. |
| 23 | docs/QUEUE_AND_CRON.md | C2 §22.4 | Horizon supervisors, schedule, Redis tuning. |
| 24 | docs/SERVER_HEALTH.md | C2 §22.5 | Health endpoint + diagnose output + alerting. |
| 25 | docs/AI_SELECTION_EDITOR.md | F1 | Global surfaces, JS layer, API, history, secrets exclusion, undo. |
| 26 | docs/SECURITY.md | Page 15 + C2 §23 | Threat model, secrets, auth, abilities, RAG redaction, push gating, audit. |
| 27 | docs/HOW_TO_START_WITH_CLAUDE_CODE.md | C1 §13 | 5-minute start, first-prompt template, safe vs blocked commands. |
| 28 | docs/CHANGELOG_AI.md | C2 §24 | Append-only log of AI-assisted changes. |
18. php artisan agent-workspace:diagnose
Single command, run locally and in CI. Returns PASS / WARN / FAIL per check.
[ ] OS is CentOS-compatible (or note Docker/macOS dev box)
[ ] LiteSpeed detected (prod) / `php artisan serve` OK (dev)
[ ] PHP 8.3.x + required extensions (mbstring, pdo_mysql, redis, zip, gd, intl, openssl, opcache, xml)
[ ] MySQL/MariaDB connection (driver must be mysql/mariadb)
[ ] Redis ping
[ ] Horizon process alive
[ ] Reverb process alive
[ ] Scheduler entry present
[ ] OpenAI API key present (in server_params or .env; never in resource output)
[ ] Claude API key present
[ ] Claude Code CLI binary on PATH (in-app provider)
[ ] Git binary on PATH
[ ] Composer binary on PATH
[ ] workspace root /var/lib/agent-workspaces writable
[ ] storage/, bootstrap/cache writable; permissions != 777
[ ] rag_chunks table exists + most recent rag_index_runs row is < 24h old
[ ] docs/ writable
[ ] api/v1 routes resolve (php artisan route:list | grep api/v1)
[ ] api/v1/runs/{run}/stream SSE responds (smoke test with curl)
[ ] server_params seeded
[ ] snapshots directory writable
[ ] CLAUDE.md and .claude/ bundle present and lint-clean (claude-rules-lint)
[ ] AI selection editor mount present in layouts/app.blade.php
[ ] iPhone parity contract test green
[ ] No file in repo matches secret regex (sk-..., ghp_..., AWS keys, JWTs)
[ ] No RAG chunk matches secret regex (php artisan rag:audit)Output is JSON when --json is passed (used by Api\HealthController). Each check returns {name, status: PASS|WARN|FAIL, detail?}.
19. Acceptance criteria — Claude Code-ready repo (re-stated)
In addition to §14:
docs/INSPECTION.mdis current after every refactor pass.
docs/REFACTOR_PLAN.mdexists for the in-flight pass (deleted once the pass merges).
- All 28 docs in §17 exist with
Status:+Last reviewed:.
php artisan agent-workspace:diagnosereturns all PASS or documented WARN.
- The Final Report (§16.6) is filled in for every refactor pass and attached to the cover PR.
<!-- ORPHAN-TAIL-DROP -->
| # | File | Owner spec | Brief |
|---|---|---|---|
| 1 | docs/PROJECT_CONTEXT.md | Hub + C2 §2 | What / why / arch lock / scope / non-goals. |
| 2 | docs/PROJECT_MAP.md | C2 §15 | Route ↔ controller ↔ model ↔ table ↔ service matrix. |
| 3 | docs/DATABASE_SCHEMA.md | C2 §16 | Every table, column, type, index, FK, JSON, encrypted, soft delete. |
| 4 | docs/DATABASE_RELATIONS.md | C2 §17 | Relationship matrix + Mermaid ER. |
| 5 | docs/ARCHITECTURE_DIAGRAMS.md | C2 §25 | All 10 Mermaid diagrams. |
| 6 | docs/API_ENDPOINTS.md | Page 14 | Every endpoint, method, auth, abilities, request/response, errors. |
| 7 | docs/ROUTES_CONTROLLERS_MODELS.md | C2 §15 | Route table with middleware/validation/resource/model/table/service/view/tests. |
| 8 | docs/SERVICES_MAP.md | C2 §15 | Service × responsibility × models × external APIs × callers × risk. |
| 9 | docs/RAG_SYSTEM.md | Page 04 | Sources, chunking, embedding, storage (MySQL JSON default), retrieval, secret exclusion. |
| 10 | docs/AGENT_WORKFLOW.md | C2 §18 | Run lifecycle, tool surface, events, snapshots, branches, pause/resume. |
| 11 | docs/AI_AGENTS.md | C2 §18 | 12 specialized agents — full contracts. |
| 12 | docs/AI_SKILLS.md | C2 §19 | 15 reusable skills — full contracts. |
| 13 | docs/RULES_SYSTEM.md | C2 §20–21 | How .claude/ • .cursor/ rules are organized, loaded, linted. |
| 14 | docs/CLAUDE_CODE_INTEGRATION.md | Page 06 + C1 + C2 | Developer CLI surface + in-app ClaudeCodeAgentService. One bundle, two surfaces. |
| 15 | docs/OPENAI_INTEGRATION.md | Page 07 | Models, endpoints, streaming, tool calls, retries, cost tracking. |
| 16 | docs/SERVER_PARAMS.md | Page 08 | Every tunable, default, range, where read, who can edit. |
| 17 | docs/GIT_WORKFLOW.md | Page 09 | Branch-per-run, snapshots, review, commit gates, push approval. |
| 18 | docs/WEB_APP_PLAN.md | Page 18 + B1 | Filament panels, Livewire components, Reverb channels, F1 wiring. |
| 19 | docs/IPHONE_APP_PLAN.md | Page 13 | SwiftUI screens, SSE, Keychain, parity contract. |
| 20 | docs/CENTOS_LITESPEED_DEPLOYMENT.md | B0 + C2 §22.1 | OS, packages, LSWS install, lsphp 8.3, vhost, SSL, Supervisor. |
| 21 | docs/LITESPEED_SECURITY.md | C2 §22.2 | .env block, .git block, headers, rewrite, SELinux. |
| 22 | docs/LITESPEED_CACHE_RULES.md | C2 §22.3 | What to cache; what to never cache. |
| 23 | docs/QUEUE_AND_CRON.md | C2 §22.4 | Horizon supervisors, schedule, Redis tuning. |
| 24 | docs/SERVER_HEALTH.md | C2 §22.5 | Health endpoint + diagnose output + alerting. |
| 25 | docs/AI_SELECTION_EDITOR.md | F1 | Global surfaces, JS layer, API, history, secrets exclusion, undo. |
| 26 | docs/SECURITY.md | Page 15 + C2 §23 | Threat model, secrets, auth, abilities, RAG redaction, push gating, audit. |
| 27 | docs/HOW_TO_START_WITH_CLAUDE_CODE.md | C1 §13 | 5-minute start, first-prompt template, safe vs blocked commands. |
| 28 | docs/CHANGELOG_AI.md | C2 §24 | Append-only log of AI-assisted changes. |
18. php artisan agent-workspace:diagnose
Single command, run locally and in CI. Returns PASS / WARN / FAIL per check.
[ ] OS is CentOS-compatible (or note Docker/macOS dev box)
[ ] LiteSpeed detected (prod) / `php artisan serve` OK (dev)
[ ] PHP 8.3.x + required extensions (mbstring, pdo_mysql, redis, zip, gd, intl, openssl, opcache, xml)
[ ] MySQL/MariaDB connection (driver must be mysql/mariadb)
[ ] Redis ping
[ ] Horizon process alive
[ ] Reverb process alive
[ ] Scheduler entry present
[ ] OpenAI API key present (in server_params or .env; never in resource output)
[ ] Claude API key present
[ ] Claude Code CLI binary on PATH (in-app provider)
[ ] Git binary on PATH
[ ] Composer binary on PATH
[ ] workspace root /var/lib/agent-workspaces writable
[ ] storage/, bootstrap/cache writable; permissions != 777
[ ] rag_chunks table exists + most recent rag_index_runs row is < 24h old
[ ] docs/ writable
[ ] api/v1 routes resolve (php artisan route:list | grep api/v1)
[ ] api/v1/runs/{run}/stream SSE responds (smoke test with curl)
[ ] server_params seeded
[ ] snapshots directory writable
[ ] CLAUDE.md and .claude/ bundle present and lint-clean (claude-rules-lint)
[ ] AI selection editor mount present in layouts/app.blade.php
[ ] iPhone parity contract test green
[ ] No file in repo matches secret regex (sk-..., ghp_..., AWS keys, JWTs)
[ ] No RAG chunk matches secret regex (php artisan rag:audit)Output is JSON when --json is passed (used by Api\HealthController). Each check returns {name, status: PASS|WARN|FAIL, detail?}.
19. Acceptance criteria — Claude Code-ready repo (re-stated)
In addition to §14:
docs/INSPECTION.mdis current after every refactor pass.
docs/REFACTOR_PLAN.mdexists for the in-flight pass (deleted once the pass merges).
- All 28 docs in §17 exist with
Status:+Last reviewed:.
php artisan agent-workspace:diagnosereturns all PASS or documented WARN.
- The Final Report (§16.6) is filled in for every refactor pass and attached to the cover PR.