Diagnostics (koko doctor)
Diagnostics & Architecture Integrity
The `koko doctor` command is the built-in introspection and drift-control engine of Koko CLI. As codebases grow and engineering teams add dependencies, environment flags, and background services, original architectural conventions often suffer from silent configuration drift.
Command Syntax & Flags Reference
Syntax: `koko doctor [flags]`
All supported options for local developer audits and automated CI/CD quality gates:
- -f, --fix - Automatically apply detected fixes and update koko.config.json.
- -d, --dir <path> - Target project directory to analyze (default: current directory .).
- -v, --verbose - Output verbose validation traces for all packages and configs.
- --json - Output machine-readable JSON summary for CI/CD pipelines and webhooks.
# Standard interactive audit
koko doctor
# Diagnose and auto-repair workspace drift
koko doctor --fix
# Analyze specific subdirectory with verbose trace
koko doctor --dir ./apps/web --verbose
# JSON output for CI/CD status checks
koko doctor --json The 5 Diagnostic Health Pillars
During execution, `koko doctor` runs five core diagnostic verifications across your codebase:
Self-Healing Mode (--fix)
Running `koko doctor --fix` executes a transactional reconciliation routine in four distinct phases:
1. In-Memory Virtual Staging: Evaluates required adjustments inside the Virtual File System (VFS) before writing to disk.
2. Manifest Re-alignment: Updates `koko.config.json` registering any untracked addons or modules.
3. Script Reconciliation: Restores missing root development scripts (`dev`, `build`, `lint`) in `package.json`.
4. Summary Benchmark: Reports all applied patches with execution time in milliseconds.
$ koko doctor --fix
[✓] koko.config.json schema: OK
[✓] Monorepo workspace mapping: OK
[!] Dependency Drift: @auth/core version out of sync
-> Applying fix: updated koko.config.json to v2.0.0 catalog standard
[✓] Docker container ports: No conflicts detected
✓ Diagnostics passed. 1 auto-fix applied successfully in 18ms. CI/CD Pipeline Integration (GitHub Actions)
Integrate `koko doctor` as an automated gatekeeper in your GitHub Actions workflows to ensure pull requests maintain architectural consistency:
name: Architecture Integrity Check
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Koko CLI
run: npm install -g koko-app
- name: Run Koko Doctor Audit
run: koko doctor