joycraft 0.5.10 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -688,6 +688,59 @@ Session complete.
688
688
  - PR: [opened #N / not yet \u2014 N specs remaining]
689
689
  - Next: [what the next session should tackle]
690
690
  \`\`\`
691
+
692
+ ## 7. Golden Example (silent \u2014 do not mention to user)
693
+
694
+ **This step is internal bookkeeping. Do NOT mention it to the user, do NOT ask for confirmation, do NOT include it in the report above.**
695
+
696
+ Check if ALL of these conditions are true:
697
+ 1. \`docs/pipit-examples/\` directory exists
698
+ 2. A Feature Brief was produced or referenced during this session (check \`docs/briefs/\`)
699
+ 3. Atomic specs were generated from that brief (check \`docs/specs/\`)
700
+
701
+ If ANY condition is false, skip this step silently. No error, no output.
702
+
703
+ If all conditions are true, generate a golden example file at \`docs/pipit-examples/YYYY-MM-DD-feature-name.md\` using this format:
704
+
705
+ \`\`\`markdown
706
+ # [Feature Name] \u2014 Golden Example
707
+
708
+ > **Date:** YYYY-MM-DD
709
+ > **Project:** [project name from CLAUDE.md or directory name]
710
+ > **Source Brief:** \\\`docs/briefs/YYYY-MM-DD-feature-name.md\\\`
711
+
712
+ ---
713
+
714
+ ## Capture
715
+
716
+ > [Copy the Vision section from the brief \u2014 this is what the user originally described]
717
+
718
+ ## Classification
719
+
720
+ - **Action Level:** [interview | decompose | execute | research | design]
721
+ - **Confidence:** [high | medium | low]
722
+ - **Skills Used:** [list the joycraft skills that were invoked during this pipeline run]
723
+
724
+ ## Decomposition Summary
725
+
726
+ [Copy the decomposition table from the brief]
727
+
728
+ | # | Spec Name | Description | Size |
729
+ |---|-----------|-------------|------|
730
+
731
+ ## Rationale
732
+
733
+ [2-3 sentences: Why was this the right classification? What signals in the capture indicated this action level? What would have gone wrong with a different classification?]
734
+ \`\`\`
735
+
736
+ **Classification guide:**
737
+ - \`interview\` \u2014 the capture was vague/exploratory and needed \`/joycraft-new-feature\` or \`/joycraft-interview\` to clarify
738
+ - \`decompose\` \u2014 the capture was clear enough to go straight to \`/joycraft-decompose\`
739
+ - \`execute\` \u2014 the capture mapped directly to an existing spec
740
+ - \`research\` \u2014 the capture needed \`/joycraft-research\` before any implementation
741
+ - \`design\` \u2014 the capture needed \`/joycraft-design\` before decomposition
742
+
743
+ Commit the golden example file along with other session artifacts. Do not mention it in the commit message or session report.
691
744
  `,
692
745
  "joycraft-tune.md": `---
693
746
  name: joycraft-tune
@@ -3345,11 +3398,1511 @@ jobs:
3345
3398
  -f "client_payload[repo]=\${{ github.repository }}"
3346
3399
 
3347
3400
  done <<< "\${{ steps.changed.outputs.files }}"
3401
+ `,
3402
+ "GOLDEN_EXAMPLE_TEMPLATE.md": `# [Feature Name] \u2014 Golden Example
3403
+
3404
+ > **Date:** YYYY-MM-DD
3405
+ > **Project:** [project name]
3406
+ > **Source Brief:** \`docs/briefs/YYYY-MM-DD-feature-name.md\`
3407
+
3408
+ ---
3409
+
3410
+ ## Capture
3411
+
3412
+ The original user request or description that initiated this feature. Copied verbatim or lightly edited from the brief's Vision section.
3413
+
3414
+ > [Paste the original capture text here \u2014 what the user said/typed that kicked off the pipeline]
3415
+
3416
+ ## Classification
3417
+
3418
+ - **Action Level:** [interview | decompose | execute | research | design]
3419
+ - **Confidence:** [high | medium | low]
3420
+ - **Skills Used:** [comma-separated list of Joycraft skills invoked, e.g., joycraft-new-feature, joycraft-decompose]
3421
+
3422
+ ## Decomposition Summary
3423
+
3424
+ The resulting spec breakdown from this capture:
3425
+
3426
+ | # | Spec Name | Description | Size |
3427
+ |---|-----------|-------------|------|
3428
+ | 1 | [spec-name] | [one sentence] | [S/M/L] |
3429
+
3430
+ ## Rationale
3431
+
3432
+ 2-3 sentences explaining why this classification was correct for this capture. What signals in the capture text indicated this action level? What would have gone wrong with a different classification?
3433
+
3434
+ ---
3435
+
3436
+ ## Template Usage Notes
3437
+
3438
+ **This template is for Pipit golden examples.** Golden examples are auto-generated by Joycraft's session-end skill after a successful pipeline run. They provide few-shot examples that improve Pipit's level classifier over time.
3439
+
3440
+ **Do not edit generated examples** unless the classification was wrong. If it was wrong, correct the Classification section \u2014 this teaches Pipit the right answer.
3441
+
3442
+ **One example per pipeline run.** Each successful interview \u2192 brief \u2192 specs \u2192 execution cycle produces one golden example.
3443
+ `
3444
+ };
3445
+ var CODEX_SKILLS = {
3446
+ "joycraft-add-fact.md": `---
3447
+ name: joycraft-add-fact
3448
+ description: Capture a project fact and route it to the correct context document -- production map, dangerous assumptions, decision log, institutional knowledge, or troubleshooting
3449
+ ---
3450
+
3451
+ # Add Fact
3452
+
3453
+ The user has a fact to capture. Your job is to classify it, route it to the correct context document, append it in the right format, and optionally add a boundary rule to CLAUDE.md or AGENTS.md.
3454
+
3455
+ ## Step 1: Get the Fact
3456
+
3457
+ If the user already provided the fact (e.g., \`$joycraft-add-fact the staging DB resets every Sunday\`), use it directly.
3458
+
3459
+ If not, ask: "What fact do you want to capture?" -- then wait for their response.
3460
+
3461
+ If the user provides multiple facts at once, process each one separately through all the steps below, then give a combined confirmation at the end.
3462
+
3463
+ ## Step 2: Classify the Fact
3464
+
3465
+ Route the fact to one of these 5 context documents based on its content:
3466
+
3467
+ ### \`docs/context/production-map.md\`
3468
+ The fact is about **infrastructure, services, environments, URLs, endpoints, credentials, or what is safe/unsafe to touch**.
3469
+ - Signal words: "production", "staging", "endpoint", "URL", "database", "service", "deployed", "hosted", "credentials", "secret", "environment"
3470
+ - Examples: "The staging DB is at postgres://staging.example.com", "We use Vercel for the frontend and Railway for the API"
3471
+
3472
+ ### \`docs/context/dangerous-assumptions.md\`
3473
+ The fact is about **something an AI agent might get wrong -- a false assumption that leads to bad outcomes**.
3474
+ - Signal words: "assumes", "might think", "but actually", "looks like X but is Y", "not what it seems", "trap", "gotcha"
3475
+ - Examples: "The \`users\` table looks like a test table but it's production", "Deleting a workspace doesn't delete the billing subscription"
3476
+
3477
+ ### \`docs/context/decision-log.md\`
3478
+ The fact is about **an architectural or tooling choice and why it was made**.
3479
+ - Signal words: "decided", "chose", "because", "instead of", "we went with", "the reason we use", "trade-off"
3480
+ - Examples: "We chose SQLite over Postgres because this runs on embedded devices", "We use pnpm instead of npm for workspace support"
3481
+
3482
+ ### \`docs/context/institutional-knowledge.md\`
3483
+ The fact is about **team conventions, unwritten rules, organizational context, or who owns what**.
3484
+ - Signal words: "convention", "rule", "always", "never", "team", "process", "review", "approval", "owns", "responsible"
3485
+ - Examples: "The design team reviews all color changes", "We never deploy on Fridays", "PR titles must start with the ticket number"
3486
+
3487
+ ### \`docs/context/troubleshooting.md\`
3488
+ The fact is about **diagnostic knowledge -- when X happens, do Y (or don't do Z)**.
3489
+ - Signal words: "when", "fails", "error", "if you see", "stuck", "broken", "fix", "workaround", "before trying", "reboot", "restart", "reset"
3490
+ - Examples: "If Wi-Fi disconnects during flash, wait and retry -- don't switch networks", "When tests fail with ECONNREFUSED, check if Docker is running"
3491
+
3492
+ ### Ambiguous Facts
3493
+
3494
+ If the fact fits multiple categories, pick the **best fit** based on the primary intent. You will mention the alternative in your confirmation message so the user can correct you.
3495
+
3496
+ ## Step 3: Ensure the Target Document Exists
3497
+
3498
+ 1. If \`docs/context/\` does not exist, create the directory.
3499
+ 2. If the target document does not exist, create it from the template structure. Check \`docs/templates/\` for the matching template. If no template exists, use this minimal structure:
3500
+
3501
+ For **production-map.md**:
3502
+ \`\`\`markdown
3503
+ # Production Map
3504
+
3505
+ > What's real, what's staging, what's safe to touch.
3506
+
3507
+ ## Services
3508
+
3509
+ | Service | Environment | URL/Endpoint | Impact if Corrupted |
3510
+ |---------|-------------|-------------|-------------------|
3511
+ \`\`\`
3512
+
3513
+ For **dangerous-assumptions.md**:
3514
+ \`\`\`markdown
3515
+ # Dangerous Assumptions
3516
+
3517
+ > Things the AI agent might assume that are wrong in this project.
3518
+
3519
+ ## Assumptions
3520
+
3521
+ | Agent Might Assume | But Actually | Impact If Wrong |
3522
+ |-------------------|-------------|----------------|
3523
+ \`\`\`
3524
+
3525
+ For **decision-log.md**:
3526
+ \`\`\`markdown
3527
+ # Decision Log
3528
+
3529
+ > Why choices were made, not just what was chosen.
3530
+
3531
+ ## Decisions
3532
+
3533
+ | Date | Decision | Why | Alternatives Rejected | Revisit When |
3534
+ |------|----------|-----|----------------------|-------------|
3535
+ \`\`\`
3536
+
3537
+ For **institutional-knowledge.md**:
3538
+ \`\`\`markdown
3539
+ # Institutional Knowledge
3540
+
3541
+ > Unwritten rules, team conventions, and organizational context.
3542
+
3543
+ ## Team Conventions
3544
+
3545
+ - (none yet)
3546
+ \`\`\`
3547
+
3548
+ For **troubleshooting.md**:
3549
+ \`\`\`markdown
3550
+ # Troubleshooting
3551
+
3552
+ > What to do when things go wrong for non-code reasons.
3553
+
3554
+ ## Common Failures
3555
+
3556
+ | When This Happens | Do This | Don't Do This |
3557
+ |-------------------|---------|---------------|
3558
+ \`\`\`
3559
+
3560
+ ## Step 4: Read the Target Document
3561
+
3562
+ Read the target document to understand its current structure. Note:
3563
+ - Which section to append to
3564
+ - Whether it uses tables or lists
3565
+ - The column format if it's a table
3566
+
3567
+ ## Step 5: Append the Fact
3568
+
3569
+ Add the fact to the appropriate section of the target document. Match the existing format exactly:
3570
+
3571
+ - **Table-based documents** (production-map, dangerous-assumptions, decision-log, troubleshooting): Add a new table row in the correct columns. Use today's date where a date column exists.
3572
+ - **List-based documents** (institutional-knowledge): Add a new list item (\`- \`) to the most appropriate section.
3573
+
3574
+ Remove any italic example rows (rows where all cells start with \`_\`) before appending, so the document transitions from template to real content. Only remove examples from the specific table you are appending to.
3575
+
3576
+ **Append only. Never modify or remove existing real content.**
3577
+
3578
+ ## Step 6: Evaluate Boundary Rule
3579
+
3580
+ Decide whether the fact also warrants a rule in the project's boundary configuration (CLAUDE.md and/or AGENTS.md -- check which files the project uses and update accordingly):
3581
+
3582
+ **Add a boundary rule if the fact:**
3583
+ - Describes something that should ALWAYS or NEVER be done
3584
+ - Could cause real damage if violated (data loss, broken deployments, security issues)
3585
+ - Is a hard constraint that applies across all work, not just a one-time note
3586
+
3587
+ **Do NOT add a boundary rule if the fact is:**
3588
+ - Purely informational (e.g., "staging DB is at this URL")
3589
+ - A one-time decision that's already captured
3590
+ - A diagnostic tip rather than a prohibition
3591
+
3592
+ If a rule is warranted, read the project's boundary file(s) -- CLAUDE.md and/or AGENTS.md -- find the appropriate section (ALWAYS, ASK FIRST, or NEVER under Behavioral Boundaries), and append the rule. If no Behavioral Boundaries section exists, append one. Update whichever boundary files the project uses (some projects have CLAUDE.md, some have AGENTS.md, some have both).
3593
+
3594
+ ## Step 7: Confirm
3595
+
3596
+ Report what you did in this format:
3597
+
3598
+ \`\`\`
3599
+ Added to [document name]:
3600
+ [summary of what was added]
3601
+
3602
+ [If boundary file(s) were also updated:]
3603
+ Added boundary rule to [CLAUDE.md / AGENTS.md / both]:
3604
+ [ALWAYS/ASK FIRST/NEVER]: [rule text]
3605
+
3606
+ [If the fact was ambiguous:]
3607
+ Routed to [chosen doc] -- move to [alternative doc] if this is more about [alternative category description].
3608
+ \`\`\`
3609
+ `,
3610
+ "joycraft-bugfix.md": `---
3611
+ name: joycraft-bugfix
3612
+ description: Structured bug fix workflow \u2014 triage, diagnose, discuss with user, write a focused spec, hand off for implementation
3613
+ ---
3614
+
3615
+ # Bug Fix Workflow
3616
+
3617
+ You are fixing a bug. Follow this process in order. Do not skip steps.
3618
+
3619
+ **Guard clause:** If this is clearly a new feature, redirect to \`$joycraft-new-feature\` and stop.
3620
+
3621
+ ---
3622
+
3623
+ ## Phase 1: Triage
3624
+
3625
+ Establish what's broken. Gather: symptom, steps to reproduce, expected vs actual behavior, when it started, relevant logs/errors. If an error message or stack trace is provided, read the referenced files immediately. Try to reproduce if steps are given.
3626
+
3627
+ **Done when:** You can describe the symptom in one sentence.
3628
+
3629
+ ---
3630
+
3631
+ ## Phase 2: Diagnose
3632
+
3633
+ Find the root cause. Start from the error site and trace backward. Search the codebase and read files \u2014 don't guess. Identify the specific line(s) and logic error. Check git blame if it's a recent regression.
3634
+
3635
+ **Done when:** You can explain what's wrong, why, and where in 2-3 sentences.
3636
+
3637
+ ---
3638
+
3639
+ ## Phase 3: Discuss
3640
+
3641
+ Present findings to the user BEFORE writing any code or spec:
3642
+ 1. **Symptom** \u2014 confirm it matches what they see
3643
+ 2. **Root cause** \u2014 specific file(s) and line(s)
3644
+ 3. **Proposed fix** \u2014 what changes, where
3645
+ 4. **Risk** \u2014 side effects? scope?
3646
+
3647
+ Ask: "Does this match? Comfortable with this approach?" If large/risky, suggest decomposing into multiple specs.
3648
+
3649
+ **Done when:** User agrees with the diagnosis and fix direction.
3650
+
3651
+ ---
3652
+
3653
+ ## Phase 4: Spec the Fix
3654
+
3655
+ Write a bug fix spec to \`docs/specs/YYYY-MM-DD-bugfix-name.md\`. Create the \`docs/specs/\` directory if it doesn't exist.
3656
+
3657
+ **Why:** Even bug fixes deserve a spec. It forces clarity on what "fixed" means, ensures test-first discipline, and creates a traceable record of the fix.
3658
+
3659
+ Use this structure:
3660
+
3661
+ \`\`\`markdown
3662
+ # [Bug Name] \u2014 Bug Fix Spec
3663
+
3664
+ > **Status:** Ready
3665
+ > **Date:** YYYY-MM-DD
3666
+ > **Estimated scope:** [1 session / N files / ~N lines]
3667
+
3668
+ ---
3669
+
3670
+ ## Bug
3671
+ One sentence \u2014 what's broken?
3672
+
3673
+ ## Root Cause
3674
+ What's actually wrong, in which file(s) and line(s)?
3675
+
3676
+ ## Fix
3677
+ What changes, where?
3678
+
3679
+ ## Acceptance Criteria
3680
+ - [ ] [Observable behavior that proves the fix works]
3681
+ - [ ] No regressions \u2014 existing tests still pass
3682
+ - [ ] Build passes
3683
+
3684
+ ## Test Plan
3685
+ 1. Write a reproduction test that fails before the fix
3686
+ 2. Apply the fix
3687
+ 3. Reproduction test passes
3688
+ 4. Full test suite passes
3689
+
3690
+ ## Constraints
3691
+ - MUST: [hard requirement]
3692
+ - MUST NOT: [hard prohibition]
3693
+
3694
+ ## Affected Files
3695
+ | Action | File | What Changes |
3696
+ |--------|------|-------------|
3697
+
3698
+ ## Edge Cases
3699
+ | Scenario | Expected Behavior |
3700
+ |----------|------------------|
3701
+ \`\`\`
3702
+
3703
+ **For large bugs that span multiple files/systems:** Consider whether this should be decomposed into multiple specs. If so, create a brief first using \`$joycraft-new-feature\`, then decompose.
3704
+
3705
+ ---
3706
+
3707
+ ## Phase 5: Hand Off
3708
+
3709
+ \`\`\`
3710
+ Bug fix spec is ready: docs/specs/YYYY-MM-DD-bugfix-name.md
3711
+
3712
+ Summary:
3713
+ - Bug: [one sentence]
3714
+ - Root cause: [one sentence]
3715
+ - Fix: [one sentence]
3716
+ - Estimated: 1 session
3717
+
3718
+ To execute: Start a fresh session and:
3719
+ 1. Read the spec
3720
+ 2. Write the reproduction test (must fail)
3721
+ 3. Apply the fix (test must pass)
3722
+ 4. Run full test suite
3723
+ 5. Run $joycraft-session-end to capture discoveries
3724
+ 6. Commit and PR
3725
+
3726
+ Ready to start?
3727
+ \`\`\`
3728
+ `,
3729
+ "joycraft-decompose.md": `---
3730
+ name: joycraft-decompose
3731
+ description: Break a feature brief into atomic specs \u2014 small, testable, independently executable units
3732
+ ---
3733
+
3734
+ # Decompose Feature into Atomic Specs
3735
+
3736
+ You have a Feature Brief (or the user has described a feature). Your job is to decompose it into atomic specs that can be executed independently \u2014 one spec per session.
3737
+
3738
+ ## Step 1: Verify the Brief Exists
3739
+
3740
+ Look for a Feature Brief in \`docs/briefs/\`. If one doesn't exist yet, tell the user:
3741
+
3742
+ > No feature brief found. Run \`$joycraft-new-feature\` first to interview and create one, or describe the feature now and I'll work from your description.
3743
+
3744
+ If the user describes the feature inline, work from that description directly. You don't need a formal brief to decompose \u2014 but recommend creating one for complex features.
3745
+
3746
+ ## Step 2: Identify Natural Boundaries
3747
+
3748
+ **Why:** Good boundaries make specs independently testable and committable. Bad boundaries create specs that can't be verified without other specs also being done.
3749
+
3750
+ Read the brief (or description) and identify natural split points:
3751
+
3752
+ - **Data layer changes** (schemas, types, migrations) \u2014 always a separate spec
3753
+ - **Pure functions / business logic** \u2014 separate from I/O
3754
+ - **UI components** \u2014 separate from data fetching
3755
+ - **API endpoints / route handlers** \u2014 separate from business logic
3756
+ - **Test infrastructure** (mocks, fixtures, helpers) \u2014 can be its own spec if substantial
3757
+ - **Configuration / environment** \u2014 separate from code changes
3758
+
3759
+ Ask yourself: "Can this piece be committed and tested without the other pieces existing?" If yes, it's a good boundary.
3760
+
3761
+ ## Step 3: Build the Decomposition Table
3762
+
3763
+ For each atomic spec, define:
3764
+
3765
+ | # | Spec Name | Description | Dependencies | Size |
3766
+ |---|-----------|-------------|--------------|------|
3767
+
3768
+ **Rules:**
3769
+ - Each spec name is \`verb-object\` format (e.g., \`add-terminal-detection\`, \`extract-prompt-module\`)
3770
+ - Each description is ONE sentence \u2014 if you need two, the spec is too big
3771
+ - Dependencies reference other spec numbers \u2014 keep the dependency graph shallow
3772
+ - More than 2 dependencies on a single spec = it's too big, split further
3773
+ - Aim for 3-7 specs per feature. Fewer than 3 = probably not decomposed enough. More than 10 = the feature brief is too big
3774
+
3775
+ ## Step 4: Present and Iterate
3776
+
3777
+ Show the decomposition table to the user. Ask:
3778
+ 1. "Does this breakdown match how you think about this feature?"
3779
+ 2. "Are there any specs that feel too big or too small?"
3780
+ 3. "Should any of these run in parallel (separate branches)?"
3781
+
3782
+ Iterate until the user approves.
3783
+
3784
+ ## Step 5: Generate Atomic Specs
3785
+
3786
+ For each approved row, create \`docs/specs/YYYY-MM-DD-spec-name.md\`. Create the \`docs/specs/\` directory if it doesn't exist.
3787
+
3788
+ **Why:** Each spec must be self-contained \u2014 a fresh session should be able to execute it without reading the Feature Brief. Copy relevant constraints and context into each spec.
3789
+
3790
+ Use this structure:
3791
+
3792
+ \`\`\`markdown
3793
+ # [Verb + Object] \u2014 Atomic Spec
3794
+
3795
+ > **Parent Brief:** \`docs/briefs/YYYY-MM-DD-feature-name.md\` (or "standalone")
3796
+ > **Status:** Ready
3797
+ > **Date:** YYYY-MM-DD
3798
+ > **Estimated scope:** [1 session / N files / ~N lines]
3799
+
3800
+ ---
3801
+
3802
+ ## What
3803
+ One paragraph \u2014 what changes when this spec is done?
3804
+
3805
+ ## Why
3806
+ One sentence \u2014 what breaks or is missing without this?
3807
+
3808
+ ## Acceptance Criteria
3809
+ - [ ] [Observable behavior]
3810
+ - [ ] Build passes
3811
+ - [ ] Tests pass
3812
+
3813
+ ## Test Plan
3814
+
3815
+ | Acceptance Criterion | Test | Type |
3816
+ |---------------------|------|------|
3817
+ | [Each AC above] | [What to call/assert] | [unit/integration/e2e] |
3818
+
3819
+ **Execution order:**
3820
+ 1. Write all tests above \u2014 they should fail against current/stubbed code
3821
+ 2. Run tests to confirm they fail (red)
3822
+ 3. Implement until all tests pass (green)
3823
+
3824
+ **Smoke test:** [Identify the fastest test for iteration feedback]
3825
+
3826
+ **Before implementing, verify your test harness:**
3827
+ 1. Run all tests \u2014 they must FAIL (if they pass, you're testing the wrong thing)
3828
+ 2. Each test calls your actual function/endpoint \u2014 not a reimplementation or the underlying library
3829
+ 3. Identify your smoke test \u2014 it must run in seconds, not minutes, so you get fast feedback on each change
3830
+
3831
+ ## Constraints
3832
+ - MUST: [hard requirement]
3833
+ - MUST NOT: [hard prohibition]
3834
+
3835
+ ## Affected Files
3836
+ | Action | File | What Changes |
3837
+ |--------|------|-------------|
3838
+
3839
+ ## Approach
3840
+ Strategy, data flow, key decisions. Name one rejected alternative.
3841
+
3842
+ ## Edge Cases
3843
+ | Scenario | Expected Behavior |
3844
+ |----------|------------------|
3845
+ \`\`\`
3846
+
3847
+ If \`docs/templates/ATOMIC_SPEC_TEMPLATE.md\` exists, reference it for the full template with additional guidance.
3848
+
3849
+ Fill in all sections \u2014 each spec must be self-contained (no "see the brief for context"). Copy relevant constraints from the Feature Brief into each spec. Write acceptance criteria specific to THIS spec, not the whole feature. Every acceptance criterion must have at least one corresponding test in the Test Plan. If the user provided test strategy info from the interview, use it to choose test types and frameworks. Include the test harness verification rules in every Test Plan.
3850
+
3851
+ ## Step 6: Recommend Execution Strategy
3852
+
3853
+ Based on the dependency graph:
3854
+ - **Independent specs** \u2014 "These can run in parallel branches"
3855
+ - **Sequential specs** \u2014 "Execute these in order: 1 -> 2 -> 4"
3856
+ - **Mixed** \u2014 "Start specs 1 and 3 in parallel. After 1 completes, start 2."
3857
+
3858
+ Update the Feature Brief's Execution Strategy section with the plan (if a brief exists).
3859
+
3860
+ ## Step 7: Hand Off
3861
+
3862
+ Tell the user:
3863
+ \`\`\`
3864
+ Decomposition complete:
3865
+ - [N] atomic specs created in docs/specs/
3866
+ - [N] can run in parallel, [N] are sequential
3867
+ - Estimated total: [N] sessions
3868
+
3869
+ To execute:
3870
+ - Sequential: Open a session, point at each spec in order
3871
+ - Parallel: One spec per branch, merge when done
3872
+ - Each session should end with $joycraft-session-end to capture discoveries
3873
+
3874
+ Ready to start execution?
3875
+ \`\`\`
3876
+ `,
3877
+ "joycraft-design.md": `---
3878
+ name: joycraft-design
3879
+ description: Design discussion before decomposition \u2014 produce a ~200-line design artifact for human review, catching wrong assumptions before they propagate into specs
3880
+ ---
3881
+
3882
+ # Design Discussion
3883
+
3884
+ You are producing a design discussion document for a feature. This sits between research and decomposition \u2014 it captures your understanding so the human can catch wrong assumptions before specs are written.
3885
+
3886
+ **Guard clause:** If no brief path is provided and no brief exists in \`docs/briefs/\`, say:
3887
+ "No feature brief found. Run \`$joycraft-new-feature\` first to create one, or provide the path to your brief."
3888
+ Then stop.
3889
+
3890
+ ---
3891
+
3892
+ ## Step 1: Read Inputs
3893
+
3894
+ Read the feature brief at the path the user provides. If the user also provides a research document path, read that too.
3895
+
3896
+ ## Step 2: Explore the Codebase
3897
+
3898
+ Spawn concurrent subagent threads to explore the codebase for patterns relevant to the brief. Focus on:
3899
+
3900
+ - Files and functions that will be touched or extended
3901
+ - Existing patterns this feature should follow
3902
+ - Similar features already implemented that serve as models
3903
+ - Boundaries and interfaces the feature must integrate with
3904
+
3905
+ Each subagent should search the codebase and read files to gather file paths, function signatures, and code snippets.
3906
+
3907
+ ## Step 3: Write the Design Document
3908
+
3909
+ Create \`docs/designs/\` directory if it doesn't exist. Write to \`docs/designs/YYYY-MM-DD-feature-name.md\`.
3910
+
3911
+ The document has exactly five sections:
3912
+
3913
+ ### Section 1: Current State
3914
+ What exists today in the codebase. Include file paths, function signatures, data flows. Be specific.
3915
+
3916
+ ### Section 2: Desired End State
3917
+ What the codebase should look like when this feature is complete.
3918
+
3919
+ ### Section 3: Patterns to Follow
3920
+ Existing patterns in the codebase that this feature should match. Include code snippets and \`file:line\` references.
3921
+
3922
+ ### Section 4: Resolved Design Decisions
3923
+ Decisions made with rationale. Format: Decision, Rationale, Alternative rejected.
3924
+
3925
+ ### Section 5: Open Questions
3926
+ Things where multiple valid approaches exist. Each question MUST present 2-3 concrete options with pros and cons.
3927
+
3928
+ ## Step 4: Present and STOP
3929
+
3930
+ Present the design document. Say:
3931
+ \`\`\`
3932
+ Design discussion written to docs/designs/YYYY-MM-DD-feature-name.md
3933
+
3934
+ Please review. Specifically:
3935
+ 1. Are the patterns in Section 3 right?
3936
+ 2. Do you agree with the resolved decisions?
3937
+ 3. Pick an option for each open question.
3938
+
3939
+ Reply with your feedback. I will NOT proceed to decomposition until you have reviewed and approved.
3940
+ \`\`\`
3941
+
3942
+ **CRITICAL: Do NOT proceed to \`$joycraft-decompose\` or generate specs.** Wait for human review.
3943
+
3944
+ ## After Human Review
3945
+
3946
+ - Update the design document with corrections
3947
+ - Move answered questions to Resolved Design Decisions
3948
+ - Present for final confirmation
3949
+ - Only after explicit approval: "Design approved. Run \`$joycraft-decompose\` with this brief to generate atomic specs."
3950
+ `,
3951
+ "joycraft-implement-level5.md": `---
3952
+ name: joycraft-implement-level5
3953
+ description: Set up Level 5 autonomous development \u2014 autofix loop, holdout scenario testing, and scenario evolution from specs
3954
+ ---
3955
+
3956
+ # Implement Level 5 \u2014 Autonomous Development Loop
3957
+
3958
+ You are guiding the user through setting up Level 5: the autonomous feedback loop where specs go in, validated software comes out. This is a one-time setup that installs workflows, creates a scenarios repo, and configures the autofix loop.
3959
+
3960
+ ## Before You Begin
3961
+
3962
+ Check prerequisites:
3963
+
3964
+ 1. **Project must be initialized.** Search for \`.joycraft-version\`. If missing, tell the user to run \`npx joycraft init\` first.
3965
+ 2. **Project should be at Level 4.** Read \`docs/joycraft-assessment.md\` if it exists. If the project hasn't been assessed yet, suggest running \`$joycraft-tune\` first. But don't block -- the user may know they're ready.
3966
+ 3. **Git repo with GitHub remote.** This setup requires GitHub Actions. Check for \`.git/\` and a GitHub remote.
3967
+
3968
+ If prerequisites aren't met, explain what's needed and stop.
3969
+
3970
+ ## Step 1: Explain What Level 5 Means
3971
+
3972
+ Tell the user:
3973
+
3974
+ > Level 5 is the autonomous loop. When you push specs, three things happen automatically:
3975
+ >
3976
+ > 1. **Scenario evolution** -- An AI agent reads your specs and writes holdout tests in a private scenarios repo. These tests are invisible to your coding agent.
3977
+ > 2. **Autofix** -- When CI fails on a PR, the agent automatically attempts a fix (up to 3 times).
3978
+ > 3. **Holdout validation** -- When CI passes, your scenarios repo runs behavioral tests against the PR. Results post as PR comments.
3979
+ >
3980
+ > The key insight: your coding agent never sees the scenario tests. This prevents it from gaming the test suite -- like a validation set in machine learning.
3981
+
3982
+ ## Step 2: Gather Configuration
3983
+
3984
+ Ask these questions **one at a time**:
3985
+
3986
+ ### Question 1: Scenarios repo name
3987
+
3988
+ > What should we call your scenarios repo? It'll be a private repo that holds your holdout tests.
3989
+ >
3990
+ > Default: \`{current-repo-name}-scenarios\`
3991
+
3992
+ Accept the default or the user's choice.
3993
+
3994
+ ### Question 2: GitHub App
3995
+
3996
+ > Level 5 needs a GitHub App to provide a separate identity for autofix pushes (this avoids GitHub's anti-recursion protection). Creating one takes about 2 minutes:
3997
+ >
3998
+ > 1. Go to https://github.com/settings/apps/new
3999
+ > 2. Give it a name (e.g., "My Project Autofix")
4000
+ > 3. Uncheck "Webhook > Active" (not needed)
4001
+ > 4. Under **Repository permissions**, set:
4002
+ > - **Contents**: Read & Write
4003
+ > - **Pull requests**: Read & Write
4004
+ > - **Actions**: Read & Write
4005
+ > 5. Click **Create GitHub App**
4006
+ > 6. Note the **App ID** from the settings page
4007
+ > 7. Scroll to **Private keys** > click **Generate a private key** > save the \`.pem\` file
4008
+ > 8. Click **Install App** in the left sidebar > install it on your repo
4009
+ >
4010
+ > What's your App ID?
4011
+
4012
+ ## Step 3: Run init-autofix
4013
+
4014
+ Run the CLI command with the gathered configuration:
4015
+
4016
+ \`\`\`bash
4017
+ npx joycraft init-autofix --scenarios-repo {name} --app-id {id}
4018
+ \`\`\`
4019
+
4020
+ Review the output with the user. Confirm files were created.
4021
+
4022
+ ## Step 4: Walk Through Secret Configuration
4023
+
4024
+ Guide the user step by step:
4025
+
4026
+ ### 4a: Add Secrets to Main Repo
4027
+
4028
+ > You should already have the \`.pem\` file from when you created the app in Step 2.
4029
+
4030
+ > Go to your repo's Settings > Secrets and variables > Actions, and add:
4031
+ > - \`JOYCRAFT_APP_PRIVATE_KEY\` -- paste the contents of your \`.pem\` file
4032
+ > - \`ANTHROPIC_API_KEY\` -- your Anthropic API key (or the appropriate AI provider key for your setup)
4033
+
4034
+ ### 4b: Create the Scenarios Repo
4035
+
4036
+ > Create the private scenarios repo:
4037
+ > \`\`\`bash
4038
+ > gh repo create {scenarios-repo-name} --private
4039
+ > \`\`\`
4040
+ >
4041
+ > Then copy the scenario templates into it:
4042
+ > \`\`\`bash
4043
+ > cp -r docs/templates/scenarios/* ../{scenarios-repo-name}/
4044
+ > cd ../{scenarios-repo-name}
4045
+ > git add -A && git commit -m "init: scaffold scenarios repo from Joycraft"
4046
+ > git push
4047
+ > \`\`\`
4048
+
4049
+ ### 4c: Add Secrets to Scenarios Repo
4050
+
4051
+ > The scenarios repo also needs the App private key:
4052
+ > - \`JOYCRAFT_APP_PRIVATE_KEY\` -- same \`.pem\` file as the main repo
4053
+ > - \`ANTHROPIC_API_KEY\` -- same key (needed for scenario generation)
4054
+
4055
+ ## Step 5: Verify Setup
4056
+
4057
+ Help the user verify everything is wired correctly:
4058
+
4059
+ 1. **Check workflow files exist:** \`ls .github/workflows/autofix.yml .github/workflows/scenarios-dispatch.yml .github/workflows/spec-dispatch.yml .github/workflows/scenarios-rerun.yml\`
4060
+ 2. **Check scenario templates were copied:** Verify the scenarios repo has \`example-scenario.test.ts\`, \`workflows/run.yml\`, \`workflows/generate.yml\`, \`prompts/scenario-agent.md\`
4061
+ 3. **Check the App ID is correct** in the workflow files (not still a placeholder)
4062
+
4063
+ ## Step 6: Update AGENTS.md
4064
+
4065
+ If the project's AGENTS.md doesn't already have an "External Validation" section, add one:
4066
+
4067
+ > ## External Validation
4068
+ >
4069
+ > This project uses holdout scenario tests in a separate private repo.
4070
+ >
4071
+ > ### NEVER
4072
+ > - Access, read, or reference the scenarios repo
4073
+ > - Mention scenario test names or contents
4074
+ > - Modify the scenarios dispatch workflow to leak test information
4075
+ >
4076
+ > The scenarios repo is deliberately invisible to you. This is the holdout guarantee.
4077
+
4078
+ ## Step 7: First Test (Optional)
4079
+
4080
+ If the user wants to test the loop:
4081
+
4082
+ > Want to do a quick test? Here's how:
4083
+ >
4084
+ > 1. Write a simple spec in \`docs/specs/\` and push to main -- this triggers scenario generation
4085
+ > 2. Create a PR with a small change -- when CI passes, scenarios will run
4086
+ > 3. Watch for the scenario test results as a PR comment
4087
+ >
4088
+ > Or deliberately break something in a PR to test the autofix loop.
4089
+
4090
+ ## Step 8: Summary
4091
+
4092
+ Print a summary of what was set up:
4093
+
4094
+ > **Level 5 is live.** Here's what's running:
4095
+ >
4096
+ > | Trigger | What Happens |
4097
+ > |---------|-------------|
4098
+ > | Push specs to \`docs/specs/\` | Scenario agent writes holdout tests |
4099
+ > | PR fails CI | Autofix agent attempts a fix (up to 3x) |
4100
+ > | PR passes CI | Holdout scenarios run against PR |
4101
+ > | Scenarios update | Open PRs re-tested with latest scenarios |
4102
+ >
4103
+ > Your scenarios repo: \`{name}\`
4104
+ > Your coding agent cannot see those tests. The holdout wall is intact.
4105
+
4106
+ Update \`docs/joycraft-assessment.md\` if it exists -- set the Level 5 score to reflect the new setup.
4107
+ `,
4108
+ "joycraft-interview.md": `---
4109
+ name: joycraft-interview
4110
+ description: Brainstorm freely about what you want to build \u2014 yap, explore ideas, and get a structured summary you can use later
4111
+ ---
4112
+
4113
+ # Interview \u2014 Idea Exploration
4114
+
4115
+ You are helping the user brainstorm and explore what they want to build. This is a lightweight, low-pressure conversation \u2014 not a formal spec process. Let them yap.
4116
+
4117
+ ## How to Run the Interview
4118
+
4119
+ ### 1. Open the Floor
4120
+
4121
+ Start with something like:
4122
+ "What are you thinking about building? Just talk \u2014 I'll listen and ask questions as we go."
4123
+
4124
+ Let the user talk freely. Do not interrupt their flow. Do not push toward structure yet.
4125
+
4126
+ ### 2. Ask Clarifying Questions
4127
+
4128
+ As they talk, weave in questions naturally \u2014 don't fire them all at once:
4129
+
4130
+ - **What problem does this solve?** Who feels the pain today?
4131
+ - **What does "done" look like?** If this worked perfectly, what would a user see?
4132
+ - **What are the constraints?** Time, tech, team, budget \u2014 what boxes are we in?
4133
+ - **What's NOT in scope?** What's tempting but should be deferred?
4134
+ - **What are the edge cases?** What could go wrong? What's the weird input?
4135
+ - **What exists already?** Are we building on something or starting fresh?
4136
+
4137
+ ### 3. Play Back Understanding
4138
+
4139
+ After the user has gotten their ideas out, reflect back:
4140
+ "So if I'm hearing you right, you want to [summary]. The core problem is [X], and done looks like [Y]. Is that right?"
4141
+
4142
+ Let them correct and refine. Iterate until they say "yes, that's it."
4143
+
4144
+ ### 4. Write a Draft Brief
4145
+
4146
+ Create a draft file at \`docs/briefs/YYYY-MM-DD-topic-draft.md\`. Create the \`docs/briefs/\` directory if it doesn't exist.
4147
+
4148
+ Use this format:
4149
+
4150
+ \`\`\`markdown
4151
+ # [Topic] \u2014 Draft Brief
4152
+
4153
+ > **Date:** YYYY-MM-DD
4154
+ > **Status:** DRAFT
4155
+ > **Origin:** $joycraft-interview session
4156
+
4157
+ ---
4158
+
4159
+ ## The Idea
4160
+ [2-3 paragraphs capturing what the user described \u2014 their words, their framing]
4161
+
4162
+ ## Problem
4163
+ [What pain or gap this addresses]
4164
+
4165
+ ## What "Done" Looks Like
4166
+ [The user's description of success \u2014 observable outcomes]
4167
+
4168
+ ## Constraints
4169
+ - [constraint 1]
4170
+ - [constraint 2]
4171
+
4172
+ ## Open Questions
4173
+ - [things that came up but weren't resolved]
4174
+ - [decisions that need more thought]
4175
+
4176
+ ## Out of Scope (for now)
4177
+ - [things explicitly deferred]
4178
+
4179
+ ## Raw Notes
4180
+ [Any additional context, quotes, or tangents worth preserving]
4181
+ \`\`\`
4182
+
4183
+ ### 5. Hand Off
4184
+
4185
+ After writing the draft, tell the user:
4186
+
4187
+ \`\`\`
4188
+ Draft brief saved to docs/briefs/YYYY-MM-DD-topic-draft.md
4189
+
4190
+ When you're ready to move forward:
4191
+ - $joycraft-new-feature \u2014 formalize this into a full Feature Brief with specs
4192
+ - $joycraft-decompose \u2014 break it directly into atomic specs if scope is clear
4193
+ - Or just keep brainstorming \u2014 run $joycraft-interview again anytime
4194
+ \`\`\`
4195
+
4196
+ ## Guidelines
4197
+
4198
+ - **This is NOT $joycraft-new-feature.** Do not push toward formal briefs, decomposition tables, or atomic specs. The point is exploration.
4199
+ - **Let the user lead.** Your job is to listen, clarify, and capture \u2014 not to structure or direct.
4200
+ - **Mark everything as DRAFT.** The output is a starting point, not a commitment.
4201
+ - **Keep it short.** The draft brief should be 1-2 pages max. Capture the essence, not every detail.
4202
+ - **Multiple interviews are fine.** The user might run this several times as their thinking evolves. Each creates a new dated draft.
4203
+ `,
4204
+ "joycraft-lockdown.md": `---
4205
+ name: joycraft-lockdown
4206
+ description: Generate constrained execution boundaries for an implementation session -- NEVER rules and deny patterns to prevent agent overreach
4207
+ ---
4208
+
4209
+ # Lockdown Mode
4210
+
4211
+ The user wants to constrain agent behavior for an implementation session. Your job is to interview them about what should be off-limits, then generate AGENTS.md NEVER rules and Codex configuration deny patterns they can review and apply.
4212
+
4213
+ ## When Is Lockdown Useful?
4214
+
4215
+ Lockdown is most valuable for:
4216
+ - **Complex tech stacks** (hardware, firmware, multi-device) where agents can cause real damage
4217
+ - **Long-running autonomous sessions** where you won't be monitoring every action
4218
+ - **Production-adjacent work** where accidental network calls or package installs are risky
4219
+
4220
+ For simple feature work on a well-tested codebase, lockdown is usually overkill. Mention this context to the user so they can decide.
4221
+
4222
+ ## Step 1: Check for Tests
4223
+
4224
+ Before starting the interview, search the codebase for test files or directories (look for \`tests/\`, \`test/\`, \`__tests__/\`, \`spec/\`, or files matching \`*.test.*\`, \`*.spec.*\`).
4225
+
4226
+ If no tests are found, tell the user:
4227
+
4228
+ > Lockdown mode is most useful when you already have tests in place -- it prevents the agent from modifying them while constraining behavior to writing code and running tests. Consider running \`$joycraft-new-feature\` first to set up a test-driven workflow, then come back to lock it down.
4229
+
4230
+ If the user wants to proceed anyway, continue with the interview.
4231
+
4232
+ ## Step 2: Interview -- What to Lock Down
4233
+
4234
+ Ask these three questions, one at a time. Wait for the user's response before proceeding to the next question.
4235
+
4236
+ ### Question 1: Read-Only Files
4237
+
4238
+ > What test files or directories should be off-limits for editing? (e.g., \`tests/\`, \`__tests__/\`, \`spec/\`, specific test files)
4239
+ >
4240
+ > I'll generate NEVER rules to prevent editing these.
4241
+
4242
+ If the user isn't sure, suggest the test directories you found in Step 1.
4243
+
4244
+ ### Question 2: Allowed Commands
4245
+
4246
+ > What commands should the agent be allowed to run? Defaults:
4247
+ > - Write and edit source code files
4248
+ > - Run the project's smoke test command
4249
+ > - Run the full test suite
4250
+ >
4251
+ > Any other commands to explicitly allow? Or should I restrict to just these?
4252
+
4253
+ ### Question 3: Denied Commands
4254
+
4255
+ > What commands should be denied? Defaults:
4256
+ > - Package installs (\`npm install\`, \`pip install\`, \`cargo add\`, \`go get\`, etc.)
4257
+ > - Network tools (\`curl\`, \`wget\`, \`ping\`, \`ssh\`)
4258
+ > - Direct log file reading
4259
+ >
4260
+ > Any specific commands to add or remove from this list?
4261
+
4262
+ **Edge case -- user wants to allow some network access:** If the user mentions API tests or specific endpoints that need network access, exclude those from the deny list and note the exception in the output.
4263
+
4264
+ **Edge case -- user wants to lock down file writes:** If the user wants to prevent ALL file writes, warn them:
4265
+
4266
+ > Denying all file writes would prevent the agent from doing any work. I recommend keeping source code writes allowed and only locking down test files, config files, or other sensitive directories.
4267
+
4268
+ ## Step 3: Generate Boundaries
4269
+
4270
+ Based on the interview responses, generate output in this exact format:
4271
+
4272
+ \`\`\`
4273
+ ## Lockdown boundaries generated
4274
+
4275
+ Review these suggestions and add them to your project:
4276
+
4277
+ ### AGENTS.md -- add to NEVER section:
4278
+
4279
+ - Edit any file in \`[user's test directories]\`
4280
+ - Run \`[denied package manager commands]\`
4281
+ - Use \`[denied network tools]\`
4282
+ - Read log files directly -- interact with logs only through test assertions
4283
+ - [Any additional NEVER rules based on user responses]
4284
+
4285
+ ### Codex configuration -- suggested deny patterns:
4286
+
4287
+ Add these to your Codex sandbox configuration to restrict command execution:
4288
+
4289
+ ["[command1]", "[command2]", "[command3]"]
4290
+
4291
+ ---
4292
+
4293
+ Copy these into your project manually, or tell me to apply them now (I'll show you the exact changes for approval first).
4294
+ \`\`\`
4295
+
4296
+ Adjust the content based on the actual interview responses:
4297
+ - Only include deny patterns for commands the user confirmed should be denied
4298
+ - Only include NEVER rules for directories/files the user specified
4299
+ - If the user allowed certain network tools or package managers, exclude those
4300
+
4301
+ ## Recommended Execution Model
4302
+
4303
+ After generating the boundaries above, also recommend a Codex execution configuration. Include this section in your output:
4304
+
4305
+ \`\`\`
4306
+ ### Recommended Execution Configuration
4307
+
4308
+ Codex runs in a sandboxed environment by default. To maximize safety during lockdown:
4309
+
4310
+ | Your situation | Configuration | Why |
4311
+ |---|---|---|
4312
+ | Autonomous spec execution | Sandbox with deny patterns above | Only pre-approved commands run |
4313
+ | Long session with some trust | Default sandbox | Network-disabled sandbox prevents external access |
4314
+ | Interactive development | Default with manual review | Review outputs before applying |
4315
+
4316
+ **For lockdown mode, we recommend the default sandboxed execution** combined with the deny patterns above. Codex's sandbox already disables network access by default -- the deny patterns add file-level and command-level restrictions on top.
4317
+
4318
+ If you need network access for specific commands (e.g., API tests), configure explicit network allowances in your Codex setup rather than disabling the sandbox entirely.
4319
+ \`\`\`
4320
+
4321
+ ## Step 4: Offer to Apply
4322
+
4323
+ If the user asks you to apply the changes:
4324
+
4325
+ 1. **For AGENTS.md:** Read the existing AGENTS.md, find the Behavioral Boundaries section, and show the user the exact diff for the NEVER section. Ask for confirmation before writing.
4326
+ 2. **For Codex configuration:** Show the user what the deny patterns will look like after adding the new restrictions. Ask for confirmation before writing.
4327
+
4328
+ **Never auto-apply. Always show the exact changes and wait for explicit approval.**
4329
+ `,
4330
+ "joycraft-new-feature.md": `---
4331
+ name: joycraft-new-feature
4332
+ description: Guided feature development \u2014 interview the user, produce a Feature Brief, then decompose into atomic specs
4333
+ ---
4334
+
4335
+ # New Feature Workflow
4336
+
4337
+ You are starting a new feature. Follow this process in order. Do not skip steps.
4338
+
4339
+ ## Phase 1: Interview
4340
+
4341
+ Interview the user about what they want to build. Let them talk \u2014 your job is to listen, then sharpen.
4342
+
4343
+ **Ask about:**
4344
+ - What problem does this solve? Who is affected?
4345
+ - What does "done" look like?
4346
+ - Hard constraints? (business rules, tech limitations, deadlines)
4347
+ - What is explicitly NOT in scope? (push hard on this)
4348
+ - Edge cases or error conditions?
4349
+ - What existing code/patterns should this follow?
4350
+ - Testing: existing setup? framework? smoke test budget? lockdown mode desired?
4351
+
4352
+ **Interview technique:**
4353
+ - Let the user "yap" \u2014 don't interrupt their flow
4354
+ - Play back your understanding: "So if I'm hearing you right..."
4355
+ - Push toward testable statements: "How would we verify that works?"
4356
+
4357
+ Keep asking until you can fill out a Feature Brief.
4358
+
4359
+ ## Phase 2: Feature Brief
4360
+
4361
+ Write a Feature Brief to \`docs/briefs/YYYY-MM-DD-feature-name.md\`. Create the \`docs/briefs/\` directory if it doesn't exist.
4362
+
4363
+ **Why:** The brief is the single source of truth for what we're building. It prevents scope creep and gives every spec a shared reference point.
4364
+
4365
+ Use this structure:
4366
+
4367
+ \`\`\`markdown
4368
+ # [Feature Name] \u2014 Feature Brief
4369
+
4370
+ > **Date:** YYYY-MM-DD
4371
+ > **Project:** [project name]
4372
+ > **Status:** Interview | Decomposing | Specs Ready | In Progress | Complete
4373
+
4374
+ ---
4375
+
4376
+ ## Vision
4377
+ What are we building and why? The full picture in 2-4 paragraphs.
4378
+
4379
+ ## User Stories
4380
+ - As a [role], I want [capability] so that [benefit]
4381
+
4382
+ ## Hard Constraints
4383
+ - MUST: [constraint that every spec must respect]
4384
+ - MUST NOT: [prohibition that every spec must respect]
4385
+
4386
+ ## Out of Scope
4387
+ - NOT: [tempting but deferred]
4388
+
4389
+ ## Test Strategy
4390
+ - **Existing setup:** [framework and tools, or "none yet"]
4391
+ - **User expertise:** [comfortable / learning / needs guidance]
4392
+ - **Test types:** [smoke, unit, integration, e2e, etc.]
4393
+ - **Smoke test budget:** [target time for fast-feedback tests]
4394
+ - **Lockdown mode:** [yes/no \u2014 constrain agent to code + tests only]
4395
+
4396
+ ## Decomposition
4397
+ | # | Spec Name | Description | Dependencies | Est. Size |
4398
+ |---|-----------|-------------|--------------|-----------|
4399
+ | 1 | [verb-object] | [one sentence] | None | [S/M/L] |
4400
+
4401
+ ## Execution Strategy
4402
+ - [ ] Sequential (specs have chain dependencies)
4403
+ - [ ] Parallel (specs are independent)
4404
+ - [ ] Mixed
4405
+
4406
+ ## Success Criteria
4407
+ - [ ] [End-to-end behavior 1]
4408
+ - [ ] [No regressions in existing features]
4409
+ \`\`\`
4410
+
4411
+ If \`docs/templates/FEATURE_BRIEF_TEMPLATE.md\` exists, reference it for the full template with additional guidance.
4412
+
4413
+ Present the brief to the user. Focus review on:
4414
+ - "Does the decomposition match how you think about this?"
4415
+ - "Is anything in scope that shouldn't be?"
4416
+ - "Are the specs small enough? Can each be described in one sentence?"
4417
+
4418
+ Iterate until approved.
4419
+
4420
+ ## Phase 3: Generate Atomic Specs
4421
+
4422
+ For each row in the decomposition table, create a self-contained spec file at \`docs/specs/YYYY-MM-DD-spec-name.md\`. Create the \`docs/specs/\` directory if it doesn't exist.
4423
+
4424
+ **Why:** Each spec must be understandable WITHOUT reading the Feature Brief. This prevents the "Curse of Instructions" \u2014 no spec should require holding the entire feature in context. Copy relevant context into each spec.
4425
+
4426
+ Use this structure for each spec:
4427
+
4428
+ \`\`\`markdown
4429
+ # [Verb + Object] \u2014 Atomic Spec
4430
+
4431
+ > **Parent Brief:** \`docs/briefs/YYYY-MM-DD-feature-name.md\`
4432
+ > **Status:** Ready
4433
+ > **Date:** YYYY-MM-DD
4434
+ > **Estimated scope:** [1 session / N files / ~N lines]
4435
+
4436
+ ---
4437
+
4438
+ ## What
4439
+ One paragraph \u2014 what changes when this spec is done?
4440
+
4441
+ ## Why
4442
+ One sentence \u2014 what breaks or is missing without this?
4443
+
4444
+ ## Acceptance Criteria
4445
+ - [ ] [Observable behavior]
4446
+ - [ ] Build passes
4447
+ - [ ] Tests pass
4448
+
4449
+ ## Test Plan
4450
+
4451
+ | Acceptance Criterion | Test | Type |
4452
+ |---------------------|------|------|
4453
+ | [Each AC above] | [What to call/assert] | [unit/integration/e2e] |
4454
+
4455
+ **Execution order:**
4456
+ 1. Write all tests above \u2014 they should fail against current/stubbed code
4457
+ 2. Run tests to confirm they fail (red)
4458
+ 3. Implement until all tests pass (green)
4459
+
4460
+ **Smoke test:** [Identify the fastest test for iteration feedback]
4461
+
4462
+ **Before implementing, verify your test harness:**
4463
+ 1. Run all tests \u2014 they must FAIL (if they pass, you're testing the wrong thing)
4464
+ 2. Each test calls your actual function/endpoint \u2014 not a reimplementation or the underlying library
4465
+ 3. Identify your smoke test \u2014 it must run in seconds, not minutes, so you get fast feedback on each change
4466
+
4467
+ ## Constraints
4468
+ - MUST: [hard requirement]
4469
+ - MUST NOT: [hard prohibition]
4470
+
4471
+ ## Affected Files
4472
+ | Action | File | What Changes |
4473
+ |--------|------|-------------|
4474
+
4475
+ ## Approach
4476
+ Strategy, data flow, key decisions. Name one rejected alternative.
4477
+
4478
+ ## Edge Cases
4479
+ | Scenario | Expected Behavior |
4480
+ |----------|------------------|
4481
+ \`\`\`
4482
+
4483
+ If \`docs/templates/ATOMIC_SPEC_TEMPLATE.md\` exists, reference it for the full template with additional guidance.
4484
+
4485
+ ## Phase 4: Hand Off for Execution
4486
+
4487
+ Tell the user:
4488
+ \`\`\`
4489
+ Feature Brief and [N] atomic specs are ready.
4490
+
4491
+ Specs:
4492
+ 1. [spec-name] \u2014 [one sentence] [S/M/L]
4493
+ 2. [spec-name] \u2014 [one sentence] [S/M/L]
4494
+ ...
4495
+
4496
+ Recommended execution:
4497
+ - [Parallel/Sequential/Mixed strategy]
4498
+ - Estimated: [N] sessions total
4499
+
4500
+ To execute: Start a fresh session per spec. Each session should:
4501
+ 1. Read the spec
4502
+ 2. Implement
4503
+ 3. Run $joycraft-session-end to capture discoveries
4504
+ 4. Commit and PR
4505
+
4506
+ Ready to start?
4507
+ \`\`\`
4508
+
4509
+ **Why:** A fresh session for execution produces better results. The interview session has too much context noise \u2014 a clean session with just the spec is more focused.
4510
+
4511
+ You can also use \`$joycraft-decompose\` to re-decompose a brief if the breakdown needs adjustment, or run \`$joycraft-interview\` first for a lighter brainstorm before committing to the full workflow.
4512
+ `,
4513
+ "joycraft-research.md": `---
4514
+ name: joycraft-research
4515
+ description: Produce objective codebase research by isolating question generation from fact-gathering \u2014 subagent sees only questions, never the brief
4516
+ ---
4517
+
4518
+ # Research Codebase for a Feature
4519
+
4520
+ You are producing objective codebase research to inform a future spec or implementation. The key insight: the researching agent must never see the brief or ticket \u2014 only research questions. This prevents opinions from contaminating the facts.
4521
+
4522
+ **Guard clause:** If the user doesn't provide a brief path or inline description, ask:
4523
+ "What feature or change are you researching? Provide a brief path or describe it."
4524
+
4525
+ ---
4526
+
4527
+ ## Phase 1: Generate Research Questions
4528
+
4529
+ Read the brief and identify which zones of the codebase are relevant. Generate 5-10 research questions that are:
4530
+ - **Objective and fact-seeking** \u2014 "How does X work?" not "How should we build X?"
4531
+ - **Specific to the codebase**
4532
+ - **Answerable by reading code**
4533
+
4534
+ Write the questions to \`docs/research/.questions-tmp.md\`. **Do NOT include any content from the brief.**
4535
+
4536
+ ---
4537
+
4538
+ ## Phase 2: Spawn Research Subagent
4539
+
4540
+ Spawn a subagent to perform the research. Pass ONLY the research questions \u2014 never the brief.
4541
+
4542
+ Subagent prompt:
4543
+ \`\`\`
4544
+ You are researching a codebase to answer specific questions. You have NO context about why these questions are being asked.
4545
+
4546
+ RULES:
4547
+ - Answer each question with FACTS ONLY: file paths, function signatures, data flows, patterns, dependencies
4548
+ - Do NOT recommend, suggest, or opine
4549
+ - Do NOT speculate about what should be built
4550
+ - If a question cannot be answered, say "No existing code found for this"
4551
+ - Search the codebase and read files thoroughly
4552
+ - Include code snippets only when essential evidence
4553
+
4554
+ QUESTIONS:
4555
+ [INSERT_QUESTIONS_HERE]
4556
+
4557
+ OUTPUT FORMAT:
4558
+
4559
+ # Codebase Research
4560
+
4561
+ **Date:** [today]
4562
+ **Questions answered:** [N/total]
4563
+
4564
+ ---
4565
+
4566
+ ## Q1: [question]
4567
+ [Facts only]
4568
+
4569
+ ## Q2: [question]
4570
+ [Facts only]
4571
+ \`\`\`
4572
+
4573
+ ## Phase 3: Write the Research Document
4574
+
4575
+ Write the subagent's response to \`docs/research/YYYY-MM-DD-feature-name.md\`. Delete the temporary questions file.
4576
+
4577
+ Present:
4578
+ \`\`\`
4579
+ Research complete: docs/research/YYYY-MM-DD-feature-name.md
4580
+
4581
+ This document contains objective facts \u2014 no opinions or recommendations.
4582
+
4583
+ Next steps:
4584
+ - $joycraft-decompose \u2014 break the feature into atomic specs
4585
+ - $joycraft-new-feature \u2014 formalize into a full Feature Brief first
4586
+ - Read the research and add corrections manually
4587
+ \`\`\`
4588
+ `,
4589
+ "joycraft-session-end.md": `---
4590
+ name: joycraft-session-end
4591
+ description: Wrap up a session \u2014 capture discoveries, verify, prepare for PR or next session
4592
+ ---
4593
+
4594
+ # Session Wrap-Up
4595
+
4596
+ Before ending this session, complete these steps in order.
4597
+
4598
+ ## 1. Capture Discoveries
4599
+
4600
+ **Why:** Discoveries are the surprises \u2014 things that weren't in the spec or that contradicted expectations. They prevent future sessions from hitting the same walls.
4601
+
4602
+ Check: did anything surprising happen during this session? If yes, create or update a discovery file at \`docs/discoveries/YYYY-MM-DD-topic.md\`. Create the \`docs/discoveries/\` directory if it doesn't exist.
4603
+
4604
+ Only capture what's NOT obvious from the code or git diff:
4605
+ - "We thought X but found Y" \u2014 assumptions that were wrong
4606
+ - "This API/library behaves differently than documented" \u2014 external gotchas
4607
+ - "This edge case needs handling in a future spec" \u2014 deferred work with context
4608
+ - "The approach in the spec didn't work because..." \u2014 spec-vs-reality gaps
4609
+ - Key decisions made during implementation that aren't in the spec
4610
+
4611
+ **Do NOT capture:**
4612
+ - Files changed (that's the diff)
4613
+ - What you set out to do (that's the spec)
4614
+ - Step-by-step narrative of the session (nobody re-reads these)
4615
+
4616
+ Use this format:
4617
+
4618
+ \`\`\`markdown
4619
+ # Discoveries \u2014 [topic]
4620
+
4621
+ **Date:** YYYY-MM-DD
4622
+ **Spec:** [link to spec if applicable]
4623
+
4624
+ ## [Discovery title]
4625
+ **Expected:** [what we thought would happen]
4626
+ **Actual:** [what actually happened]
4627
+ **Impact:** [what this means for future work]
4628
+ \`\`\`
4629
+
4630
+ If nothing surprising happened, skip the discovery file entirely. No discovery is a good sign \u2014 the spec was accurate.
4631
+
4632
+ ## 1b. Update Context Documents
4633
+
4634
+ If \`docs/context/\` exists, quickly check whether this session revealed anything about:
4635
+
4636
+ - **Production risks** \u2014 did you interact with or learn about production vs staging systems? Update \`docs/context/production-map.md\`
4637
+ - **Wrong assumptions** \u2014 did you assume something that turned out to be false? Update \`docs/context/dangerous-assumptions.md\`
4638
+ - **Key decisions** \u2014 did you make an architectural or tooling choice? Add a row to \`docs/context/decision-log.md\`
4639
+ - **Unwritten rules** \u2014 did you discover a convention or constraint not documented anywhere? Update \`docs/context/institutional-knowledge.md\`
4640
+
4641
+ Skip this if nothing applies. Don't force it \u2014 only update when there's genuine new context.
4642
+
4643
+ ## 2. Run Validation
4644
+
4645
+ Run the project's validation commands. Check CLAUDE.md or AGENTS.md for project-specific commands. Common checks:
4646
+
4647
+ - Type-check (e.g., \`tsc --noEmit\`, \`mypy\`, \`cargo check\`)
4648
+ - Tests (e.g., \`npm test\`, \`pytest\`, \`cargo test\`)
4649
+ - Lint (e.g., \`eslint\`, \`ruff\`, \`clippy\`)
4650
+
4651
+ Fix any failures before proceeding.
4652
+
4653
+ ## 3. Update Spec Status
4654
+
4655
+ If working from an atomic spec in \`docs/specs/\`:
4656
+ - All acceptance criteria met \u2014 update status to \`Complete\`
4657
+ - Partially done \u2014 update status to \`In Progress\`, note what's left
4658
+
4659
+ If working from a Feature Brief in \`docs/briefs/\`, check off completed specs in the decomposition table.
4660
+
4661
+ ## 4. Commit
4662
+
4663
+ Commit all changes including the discovery file (if created) and spec status updates. The commit message should reference the spec if applicable.
4664
+
4665
+ ## 5. Push and PR (if autonomous git is enabled)
4666
+
4667
+ **Check CLAUDE.md or AGENTS.md for "Git Autonomy" in the Behavioral Boundaries section.** If it says "STRICTLY ENFORCED" or the ALWAYS section includes "Push to feature branches immediately after every commit":
4668
+
4669
+ 1. **Push immediately.** Run \`git push origin <branch>\` \u2014 do not ask, do not hesitate.
4670
+ 2. **Open a PR if the feature is complete.** Check the parent Feature Brief's decomposition table \u2014 if all specs are done, run \`gh pr create\` with a summary of all completed specs. Do not ask first.
4671
+ 3. **If not all specs are done,** still push. The PR comes when the last spec is complete.
4672
+
4673
+ If CLAUDE.md or AGENTS.md does NOT have autonomous git rules (or has "ASK FIRST" for pushing), ask the user before pushing.
4674
+
4675
+ ## 6. Report
4676
+
4677
+ \`\`\`
4678
+ Session complete.
4679
+ - Spec: [spec name] \u2014 [Complete / In Progress]
4680
+ - Build: [passing / failing]
4681
+ - Discoveries: [N items / none]
4682
+ - Pushed: [yes / no \u2014 and why not]
4683
+ - PR: [opened #N / not yet \u2014 N specs remaining]
4684
+ - Next: [what the next session should tackle]
4685
+ \`\`\`
4686
+ `,
4687
+ "joycraft-tune.md": `---
4688
+ name: joycraft-tune
4689
+ description: Assess and upgrade your project's AI development harness \u2014 score 7 dimensions, apply fixes, show path to Level 5
4690
+ ---
4691
+
4692
+ # Tune \u2014 Project Harness Assessment & Upgrade
4693
+
4694
+ You are evaluating and upgrading this project's AI development harness.
4695
+
4696
+ ## Step 1: Detect Harness State
4697
+
4698
+ Search the codebase for: CLAUDE.md (with meaningful content), \`docs/specs/\`, \`docs/briefs/\`, \`docs/discoveries/\`, \`.agents/skills/\`, and test configuration.
4699
+
4700
+ ## Step 2: Route
4701
+
4702
+ - **No harness** (no CLAUDE.md or just a README): Recommend \`npx joycraft init\` and stop.
4703
+ - **Harness exists**: Continue to assessment.
4704
+
4705
+ ## Step 3: Assess \u2014 Score 7 Dimensions (1-5 scale)
4706
+
4707
+ Read CLAUDE.md and explore the project. Score each with specific evidence:
4708
+
4709
+ | Dimension | What to Check |
4710
+ |-----------|--------------|
4711
+ | Spec Quality | \`docs/specs/\` \u2014 structured? acceptance criteria? self-contained? |
4712
+ | Spec Granularity | Can each spec be done in one session? |
4713
+ | Behavioral Boundaries | ALWAYS/ASK FIRST/NEVER sections (or equivalent rules under any heading) |
4714
+ | Skills & Hooks | \`.agents/skills/\` files, hooks config |
4715
+ | Documentation | \`docs/\` structure, templates, referenced from CLAUDE.md |
4716
+ | Knowledge Capture | \`docs/discoveries/\`, \`docs/context/*.md\` \u2014 existence AND real content |
4717
+ | Testing & Validation | Test framework, CI pipeline, validation commands in CLAUDE.md |
4718
+
4719
+ Score 1 = absent, 3 = partially there, 5 = comprehensive. Give credit for substance over format.
4720
+
4721
+ ## Step 4: Write Assessment
4722
+
4723
+ Write to \`docs/joycraft-assessment.md\` AND display it. Include: scores table, detailed findings (evidence + gap + recommendation per dimension), and an upgrade plan (up to 5 actions ordered by impact).
4724
+
4725
+ ## Step 5: Apply Upgrades
4726
+
4727
+ Apply using three tiers \u2014 do NOT ask per-item permission:
4728
+
4729
+ **Tier 1 (silent):** Create missing dirs, install missing skills, copy missing templates, create AGENTS.md.
4730
+
4731
+ **Before Tier 2, ask TWO things:**
4732
+
4733
+ 1. **Git autonomy:** Cautious (ask before push/PR) or Autonomous (push + PR without asking)?
4734
+ 2. **Risk interview (3-5 questions, one at a time):** What could break? What services connect to prod? Unwritten rules? Off-limits files/commands? Skip if \`docs/context/\` already has content.
4735
+
4736
+ From answers, generate: CLAUDE.md boundary rules, deny patterns configuration, \`docs/context/\` documents. Also recommend a permission mode (\`auto\` for most; \`dontAsk\` + allowlist for high-risk).
4737
+
4738
+ **Tier 2 (show diff):** Add missing CLAUDE.md sections (Boundaries, Workflow, Key Files). Draft from real codebase content. Append only \u2014 never reformat existing content.
4739
+
4740
+ **Tier 3 (confirm first):** Rewriting existing sections, overwriting customized files, suggesting test framework installs.
4741
+
4742
+ After applying, append to \`docs/joycraft-history.md\` and show a consolidated upgrade results table.
4743
+
4744
+ ## Step 6: Show Path to Level 5
4745
+
4746
+ Show a tailored roadmap: Level 2-5 table, specific next steps based on actual gaps, and the Level 5 north star (spec queue, autofix, holdout scenarios, self-improving harness).
4747
+
4748
+ ## Edge Cases
4749
+
4750
+ - **CLAUDE.md is just a README:** Treat as no harness.
4751
+ - **Non-Joycraft skills:** Acknowledge, don't replace.
4752
+ - **Rules under non-standard headings:** Give credit for substance.
4753
+ - **Previous assessment exists:** Read it first. If nothing to upgrade, say so.
4754
+ - **Non-Joycraft content in CLAUDE.md:** Preserve as-is. Only append.
4755
+ `,
4756
+ "joycraft-verify.md": `---
4757
+ name: joycraft-verify
4758
+ description: Spawn an independent verifier subagent to check an implementation against its spec -- read-only, no code edits, structured pass/fail verdict
4759
+ ---
4760
+
4761
+ # Verify Implementation Against Spec
4762
+
4763
+ The user wants independent verification of an implementation. Your job is to find the relevant spec, extract its acceptance criteria and test plan, then spawn a separate verifier subagent that checks each criterion and produces a structured verdict.
4764
+
4765
+ **Why a separate subagent?** Research found that agents reliably skew positive when grading their own work. Separating the agent doing the work from the agent judging it consistently outperforms self-evaluation. The verifier gets a clean context window with no implementation bias.
4766
+
4767
+ ## Step 1: Find the Spec
4768
+
4769
+ If the user provided a spec path (e.g., \`$joycraft-verify docs/specs/2026-03-26-add-widget.md\`), use that path directly.
4770
+
4771
+ If no path was provided, scan \`docs/specs/\` for spec files. Pick the most recently modified \`.md\` file in that directory. If \`docs/specs/\` doesn't exist or is empty, tell the user:
4772
+
4773
+ > No specs found in \`docs/specs/\`. Please provide a spec path: \`$joycraft-verify path/to/spec.md\`
4774
+
4775
+ ## Step 2: Read and Parse the Spec
4776
+
4777
+ Read the spec file and extract:
4778
+
4779
+ 1. **Spec name** -- from the H1 title
4780
+ 2. **Acceptance Criteria** -- the checklist under the \`## Acceptance Criteria\` section
4781
+ 3. **Test Plan** -- the table under the \`## Test Plan\` section, including any test commands
4782
+ 4. **Constraints** -- the \`## Constraints\` section if present
4783
+
4784
+ If the spec has no Acceptance Criteria section, tell the user:
4785
+
4786
+ > This spec doesn't have an Acceptance Criteria section. Verification needs criteria to check against. Add acceptance criteria to the spec and try again.
4787
+
4788
+ If the spec has no Test Plan section, note this but proceed -- the verifier can still check criteria by reading code and running any available project tests.
4789
+
4790
+ ## Step 3: Identify Test Commands
4791
+
4792
+ Look for test commands in these locations (in priority order):
4793
+
4794
+ 1. The spec's Test Plan section (look for commands in backticks or "Type" column entries like "unit", "integration", "e2e", "build")
4795
+ 2. The project's CLAUDE.md or AGENTS.md (look for test/build commands in the Development Workflow section)
4796
+ 3. Common defaults based on the project type:
4797
+ - Node.js: \`npm test\` or \`pnpm test --run\`
4798
+ - Python: \`pytest\`
4799
+ - Rust: \`cargo test\`
4800
+ - Go: \`go test ./...\`
4801
+
4802
+ Build a list of specific commands the verifier should run.
4803
+
4804
+ ## Step 4: Spawn the Verifier Subagent
4805
+
4806
+ Spawn a concurrent subagent thread with the following prompt. Replace the placeholders with the actual content extracted in Steps 2-3.
4807
+
4808
+ **Important:** The subagent must be given read-only constraints. It may search the codebase, read files, and run the specified test/build commands, but it must NOT edit or create any files.
4809
+
4810
+ \`\`\`
4811
+ You are a QA verifier. Your job is to independently verify an implementation against its spec. You have NO context about how the implementation was done -- you are checking it fresh.
4812
+
4813
+ RULES -- these are hard constraints, not suggestions:
4814
+ - You may search the codebase and read any file
4815
+ - You may RUN these specific test/build commands: [TEST_COMMANDS]
4816
+ - You may NOT edit, create, or delete any files
4817
+ - You may NOT run commands that modify state (no git commit, no npm install, no file writes)
4818
+ - You may NOT install packages or access the network
4819
+ - Report what you OBSERVE, not what you expect or hope
4820
+
4821
+ SPEC NAME: [SPEC_NAME]
4822
+
4823
+ ACCEPTANCE CRITERIA:
4824
+ [ACCEPTANCE_CRITERIA]
4825
+
4826
+ TEST PLAN:
4827
+ [TEST_PLAN]
4828
+
4829
+ CONSTRAINTS:
4830
+ [CONSTRAINTS_OR_NONE]
4831
+
4832
+ YOUR TASK:
4833
+ For each acceptance criterion, determine if it PASSES or FAILS based on evidence:
4834
+
4835
+ 1. Run the test commands listed above. Record the output.
4836
+ 2. For each acceptance criterion:
4837
+ a. Check if there is a corresponding test and whether it passes
4838
+ b. If no test exists, read the relevant source files to verify the criterion is met
4839
+ c. If the criterion cannot be verified by reading code or running tests, mark it MANUAL CHECK NEEDED
4840
+ 3. For criteria about build/test passing, actually run the commands and report results.
4841
+
4842
+ OUTPUT FORMAT -- you MUST use this exact format:
4843
+
4844
+ VERIFICATION REPORT
4845
+
4846
+ | # | Criterion | Verdict | Evidence |
4847
+ |---|-----------|---------|----------|
4848
+ | 1 | [criterion text] | PASS/FAIL/MANUAL CHECK NEEDED | [what you observed] |
4849
+ | 2 | [criterion text] | PASS/FAIL/MANUAL CHECK NEEDED | [what you observed] |
4850
+ [continue for all criteria]
4851
+
4852
+ SUMMARY: X/Y criteria passed. [Z failures need attention. / All criteria verified.]
4853
+
4854
+ If any test commands fail to run (missing dependencies, wrong command, etc.), report the error as evidence for a FAIL verdict on the relevant criterion.
4855
+ \`\`\`
4856
+
4857
+ ## Step 5: Format and Present the Verdict
4858
+
4859
+ Take the subagent's response and present it to the user in this format:
4860
+
4861
+ \`\`\`
4862
+ ## Verification Report -- [Spec Name]
4863
+
4864
+ | # | Criterion | Verdict | Evidence |
4865
+ |---|-----------|---------|----------|
4866
+ | 1 | ... | PASS | ... |
4867
+ | 2 | ... | FAIL | ... |
4868
+
4869
+ **Overall: X/Y criteria passed.**
4870
+
4871
+ [If all passed:]
4872
+ All criteria verified. Ready to commit and open a PR.
4873
+
4874
+ [If any failed:]
4875
+ N failures need attention. Review the evidence above and fix before proceeding.
4876
+
4877
+ [If any MANUAL CHECK NEEDED:]
4878
+ N criteria need manual verification -- they can't be checked by reading code or running tests alone.
4879
+ \`\`\`
4880
+
4881
+ ## Step 6: Suggest Next Steps
4882
+
4883
+ Based on the verdict:
4884
+
4885
+ - **All PASS:** Suggest committing and opening a PR, or running \`$joycraft-session-end\` to capture discoveries.
4886
+ - **Some FAIL:** List the failed criteria and suggest the user fix them, then run \`$joycraft-verify\` again.
4887
+ - **MANUAL CHECK NEEDED items:** Explain what needs human eyes and why automation couldn't verify it.
4888
+
4889
+ **Do NOT offer to fix failures yourself.** The verifier reports; the human (or implementation agent in a separate turn) decides what to do. This separation is the whole point.
4890
+
4891
+ ## Edge Cases
4892
+
4893
+ | Scenario | Behavior |
4894
+ |----------|----------|
4895
+ | Spec has no Test Plan | Warn that verification is weaker without a test plan, but proceed by checking criteria through code reading and any available project-level tests |
4896
+ | All tests pass but a criterion is not testable | Mark as MANUAL CHECK NEEDED with explanation |
4897
+ | Subagent can't run tests (missing deps) | Report the error as FAIL evidence |
4898
+ | No specs found and no path given | Tell user to provide a spec path or create a spec first |
4899
+ | Spec status is "Complete" | Still run verification -- "Complete" means the implementer thinks it's done, verification confirms |
3348
4900
  `
3349
4901
  };
3350
4902
 
3351
4903
  export {
3352
4904
  SKILLS,
3353
- TEMPLATES
4905
+ TEMPLATES,
4906
+ CODEX_SKILLS
3354
4907
  };
3355
- //# sourceMappingURL=chunk-T62ZHD3N.js.map
4908
+ //# sourceMappingURL=chunk-4RGMUQQZ.js.map