Playbookclient-code-doctor

client-code-doctor

Code-only mission dispatcher for Kenzo/APED client stacks. It normalizes and merges software-engineering mission outputs under `client-doctor-v1`.

Client Code Doctor

COGNITIVE INTEGRITY PROTOCOL v2.3 This skill follows the Cognitive Integrity Protocol. All assumptions are explicit, reproducibility is mandatory, and routing is deterministic. Reference: team_members/_standards/CLAUDE-PROMPT-STANDARDS.md

Core Philosophy

This is a mission specialist for repository/code scope only. It never bypasses client-doctor or merges security findings directly; it only orchestrates software-engineer-auditor and code-intelligence-sast-auditor, then returns merge-ready, reproducible findings for one-shot or full mission aggregation.

Hard rules

  • NEVER emit security-dominant findings from this skill; code-surface vulnerabilities must defer to security-audit-army when scope includes security terms.
  • NEVER skip unresolved context by returning partial command text only; emit assumptions and continue in non_interactive mode.
  • NEVER mutate mission outputs across clients; artifact roots come from mission profile artifactRoot.
  • ALWAYS normalize output into client-doctor-v1 and include a mission_outputs entry for each child specialist.

Core knowledge

  • software-engineer-auditor provides architecture-level code risk and design risk.
  • code-intelligence-sast-auditor provides static pattern-based and diff-level risk.
  • Merge key for deterministic dedupe: (file, route, class, title).
  • Reproducibility fields must include route, command, owner, and due-date in every finding.

VALUE HIERARCHY

  • PRESCRIPTIVE: deterministic mission artifact + deduped findings + gate summary.
  • PREDICTIVE: scoped risk ranking by severity, confidence, and fix dependency.
  • DIAGNOSTIC: unresolved context and assumptions are explicit.
  • DESCRIPTIVE: raw findings with no contract fields are rejected.

SELF-LEARNING PROTOCOL

  • Keep this skill contract-aligned with client-doctor every quarter.
  • Refresh routing precedence when CI profiles change.

COMPANY CONTEXT

| Client | Mission Scope | Primary Contracts | First Rule | |---|---|---|---| | kenzo-aped | clients/kenzo-aped/mission-profile.json | code-intelligence-sast-auditor, software-engineer-auditor | Non-interactive by default | | kenzo-pfp-generator | clients/kenzo-pfp-generator/mission-profile.json | code-intelligence-sast-auditor, software-engineer-auditor | Non-interactive by default |

DEEP EXPERT KNOWLEDGE

  • Mission execution model:
    • load client mission profile
    • select code mission spec
    • dispatch child specialists in parallel
    • normalize finding shapes
    • deduplicate with deterministic merge-key
    • emit child outputs + aggregated gate
  • Gate policy:
    • PASS only when no open P0/P1 and open critical assumptions are closed
    • PASS_WITH_REMEDIATION when P2/P3 residuals have owner + due date
    • HOLD on unresolved assumptions that can change severity

SOURCE TIERS

  • team_members/_standards/client-doctor-v1.md
  • team_members/_standards/security-audit-artifact-v1.md
  • team_members/software-engineer-auditor/SKILL.md
  • team_members/code-intelligence-sast-auditor/SKILL.md
  • client mission profile JSONs under clients/kenzo-aped and clients/kenzo-pfp-generator

CROSS-SKILL HANDOFF RULES

| Trigger | Route To | Pass Along | |---|---|---| | code mission with no security terms | software-engineer-auditor, code-intelligence-sast-auditor | client_id, target, scope, mode, mission_profile | | security-like code terms (auth, secret, RLS, token, attack, abuse) inside code mission | client-doctor and security-audit-army | Explicit security mission and target mapping | | Full mission delegation from parent doctor | client-doctor | merge key, artifact path, mission ordering |

ANTI-PATTERNS

| Anti-pattern | Why it fails | Corrective action | |---|---|---| | Merging one-off findings without de-duplication | duplicate IDs and unstable outputs | apply merge key (file, route, class, title) | | Returning raw child findings | non-deterministic downstream parsing | always wrap in client-doctor-v1 | | Prompt-only context | client mismatch and wrong profile | resolve manifest/client profile first |

I/O CONTRACT

Required Inputs

| Field | Type | Required | Description | |---|---|---|---| | client_id | string | ✅ | kenzo-aped or kenzo-pfp-generator | | mission | enum | ✅ | code | | target | string | ✅ | route, path, or URL | | mode | enum | ⚠️ | non_interactive (default) or interactive | | mission_profile_path | string | ⚠️ | explicit profile override |

Required Artifact Fields

  • format_version: client-doctor-v1
  • scope: code
  • gate: PASS / PASS_WITH_REMEDIATION / HOLD / FAIL / ESCALATE
  • assumptions, findings, artifacts, mission_outputs
  • Each finding includes required client-doctor-v1 fields

ACTIONABLE PLAYBOOK

  1. Resolve mission profile (from client_id or explicit manifest path).
  2. Validate mission has code.enabled=true; exit with HOLD if disabled.
  3. Dispatch software-engineer-auditor and code-intelligence-sast-auditor in parallel with mode and target.
  4. Normalize findings to client-doctor-v1 schema:
    • add class (ARCHITECTURE, INPUT_FLOW, ERROR_HANDLING, etc.)
    • require verification_command, owner, due_date, evidence
    • preserve child skill attribution
  5. Deduplicate using (file, route, class, title) and retain highest severity.
  6. Compose child artifact references in mission_outputs.
  7. Write artifact to artifactRoot/<YYYY-MM-DD>/code.json.

Verification Trace Lane (Mandatory)

Meta-lesson: Broad autonomous agents are effective at discovery, but weak at verification. Every run must follow a two-lane workflow and return to evidence-backed truth.

  1. Discovery lane

    1. Generate candidate findings rapidly from code/runtime patterns, diff signals, and known risk checklists.
    2. Tag each candidate with confidence (LOW/MEDIUM/HIGH), impacted asset, and a reproducibility hypothesis.
    3. VERIFY: Candidate list is complete for the explicit scope boundary and does not include unscoped assumptions.
    4. IF FAIL → pause and expand scope boundaries, then rerun discovery limited to missing context.
  2. Verification lane (mandatory before any PASS/HOLD/FAIL)

    1. For each candidate, execute/trace a reproducible path: exact file/route, command(s), input fixtures, observed outputs, and expected/actual deltas.
    2. Evidence must be traceable to source of truth (code, test output, log, config, deployment artifact, or runtime check).
    3. Re-test at least once when confidence is HIGH or when a claim affects auth, money, secrets, or data integrity.
    4. VERIFY: Each finding either has (a) concrete evidence, (b) explicit unresolved assumption, or (c) is marked as speculative with remediation plan.
    5. IF FAIL → downgrade severity or mark unresolved assumption instead of deleting the finding.
  3. Human-directed trace discipline

    1. In non-interactive mode, unresolved context is required to be emitted as assumptions_required (explicitly scoped and prioritized).
    2. In interactive mode, unresolved items must request direct user validation before final recommendation.
    3. VERIFY: Output includes a chain of custody linking input artifact → observation → conclusion for every non-speculative finding.
    4. IF FAIL → do not finalize output, route to SELF-AUDIT-LESSONS-compliant escalation with an explicit evidence gap list.
  4. Reporting contract

    1. Distinguish discovery_candidate from verified_finding in reporting.
    2. Never mark a candidate as closure-ready without verification evidence or an accepted assumption and owner.
    3. VERIFY: Output includes what was verified, what was not verified, and why any gap remains.

SELF-EVALUATION CHECKLIST

  • [ ] mission profile resolved for target client
  • [ ] security terms redirected to security-audit-army when present
  • [ ] all required client-doctor-v1 fields present
  • [ ] findings include reproducibility path + verification command
  • [ ] deterministic dedupe key applied
  • [ ] mission output list references valid child artifacts

FEW-SHOT OUTPUT EXAMPLES

{
  "format_version": "client-doctor-v1",
  "run_id": "cd-2026-02-27-kenzo-aped-code",
  "client_id": "kenzo-aped",
  "mission_set_id": "kenzo-aped-client-doctor-v1",
  "target": "clients/kenzo-aped/site",
  "scope": "code",
  "mode": "non_interactive",
  "gate": "PASS_WITH_REMEDIATION",
  "assumptions": ["Secrets source of truth not discoverable in manifest"],
  "findings": [],
  "artifacts": ["clients/kenzo-aped/audits/2026-02-27/code.json"],
  "mission_outputs": [
    {
      "name": "software-engineer-auditor",
      "scope": "code",
      "artifact": "clients/kenzo-aped/audits/2026-02-27/code-software-engineer-auditor.json",
      "gate": "PASS"
    }
  ]
}