Deepen plan

From jikig-ai/soleur · View interactive version

Deepen plan is an AI agent skill from the GitHub repository jikig-ai/soleur. This skill should be used when enhancing an existing plan with parallel research agents for each section.

How to use this skill

Skill file

<!-- soleur-cloud-mode:start -->

Cloud Mode (Devin): before pipeline work run bash "${CLAUDE_PLUGIN_ROOT}/scripts/cloud-detect.sh". If CLAUDE_PLUGIN_ROOT is unset (cloud exec shells do not export it), resolve the root by IDENTITY, never by script basename: for d in "$HOME/.local/share/devin/cli/plugins/cache" and /opt/.devin/plugins, skip unless [ -d "$d" ], then MANIFEST="$(find "$d" -path '*/.claude-plugin/plugin.json' -exec grep -l '"name"[[:space:]]*:[[:space:]]*"soleur"' {} + 2>/dev/null | head -1)", ROOT="${MANIFEST%/.claude-plugin/plugin.json}" — one resolution, two consumers: $ROOT/scripts/cloud-detect.sh and $ROOT/scripts/precommit-guard.sh. (Shape check, not authentication: a planted {"name":"soleur"} dir passes — ADR-179 A11.) local or not-local:no-devin-env proceeds normally; any other not-local:<reason> applies <plugin-root>/devin/INSTRUCTIONS.md §Cloud Mode: emit the --banner, fan out sequentially with Reviewed-Coverage: sequential-fallback disclosure (never claim an independent review ran), message_user ack before any secrets read or production mutation, and run precommit-guard.sh before any git commit — hooks do not fire in cloud.

<!-- soleur-cloud-mode:end -->

<!-- grok-harness-invoke:start -->

Grok Build (plugins/soleur/lib/harness.ts invokeSkill()): Read this SKILL.md in this process and run it to completion. A one-segment soleur:<name> in this document names a SKILL — on Grok Build, Read plugins/soleur/skills/<name>/SKILL.md in this process; it is not a nested tool_use. A multi-segment id such as soleur:<domain>:<name> names an AGENT: spawn it, never Read it, and on Grok Build spawn_subagent takes the id with its colons replaced by hyphens (agentIdToGrokSubagentType). Claude Code: Skill tool for a skill (soleur:<name>), Task tool with subagent_type for an agent. Forbidden is executing a subset, not the Read.

<!-- grok-harness-invoke:end -->

Dynamic-workflow alternative (opt-in). A CODE0-tool port of this skill lives at CODE1 — deterministic fan-out, journaled resume, schema-validated output. Run it with Workflow({ scriptPath: "plugins/soleur/skills/deepen-plan/workflows/deepen-plan.workflow.js", args: ... }). The prose skill below stays the default; the two coexist during calibration. Known divergence: the port's GATES covers §§4.6–4.9 + the §4.13 mirror; §4.10–4.12 are prose-only — a workflow run never enforces them. See CODE4.

Deepen Plan - Power Enhancement Mode

Introduction

Note: The current year is 2026. Use this when searching for recent documentation and best practices.

This skill takes an existing plan (from the soleur:plan skill) and enhances each section with parallel research agents. Each major element gets its own dedicated research sub-agent to find:

The result is a deeply grounded, production-ready plan with concrete implementation details.

Plan File

<plan_path> #$ARGUMENTS </plan_path>

If the plan path above is empty:

  1. Check for recent plans: ls -la knowledge-base/project/plans/
  2. Ask the user: "Which plan would you like to deepen? Please provide the path (e.g., knowledge-base/project/plans/2026-01-15-feat-my-feature-plan.md)."

Do not proceed until a valid plan file path is provided.

Main Tasks

1. Parse and Analyze Plan Structure

Read the plan file and extract:

Create a section manifest:

Section 1: [Title] - [Brief description of what to research]
Section 2: [Title] - [Brief description of what to research]
...

2. Discover and Apply Available Skills

Step 1: Discover ALL available skills from ALL sources

# 1. Project-local skills (highest priority - project-specific)
ls .claude/skills/

# 2. User's global skills (~/.claude/)
ls ~/.claude/skills/

# 3. soleur plugin skills
ls ~/.claude/plugins/cache/*/soleur/*/skills/

# 4. ALL other installed plugins - check every plugin for skills
find ~/.claude/plugins/cache -type d -name "skills" 2>/dev/null

# 5. Also check installed_plugins.json for all plugin locations
cat ~/.claude/plugins/installed_plugins.json

Important: Check EVERY source. Don't assume soleur is the only plugin. Use skills from ANY installed plugin that's relevant.

Step 2: For each discovered skill, read its SKILL.md to understand what it does

# For each skill directory found, read its documentation
cat [skill-path]/SKILL.md

Step 3: Match skills to plan content

For each skill discovered:

Step 4: Spawn a sub-agent for EVERY matched skill

CRITICAL: For EACH skill that matches, spawn a separate sub-agent and instruct it to USE that skill.

For each matched skill:

Task general-purpose: "You have the [skill-name] skill available at [skill-path].

YOUR JOB: Use this skill on the plan.

1. Read the skill: cat [skill-path]/SKILL.md
2. Follow the skill's instructions exactly
3. Apply the skill to this content:

[relevant plan section or full plan]

4. Return the skill's full output

The skill tells you what to do - follow it. Execute the skill completely."

Spawn ALL skill sub-agents in PARALLEL:

Each sub-agent:

  1. Reads its skill's SKILL.md
  2. Follows the skill's workflow/instructions
  3. Applies the skill to the plan
  4. Returns whatever the skill produces (code, recommendations, patterns, reviews, etc.)

Example spawns:

Task general-purpose: "Use the dhh-rails-style skill at ~/.claude/plugins/.../dhh-rails-style. Read SKILL.md and apply it to: [Rails sections of plan]"

Task general-purpose: "Use the frontend-design skill at ~/.claude/plugins/.../frontend-design. Read SKILL.md and apply it to: [UI sections of plan]"

Task general-purpose: "Use the agent-native-architecture skill at ~/.claude/plugins/.../agent-native-architecture. Read SKILL.md and apply it to: [agent/tool sections of plan]"

Task general-purpose: "Use the security-patterns skill at ~/.claude/skills/security-patterns. Read SKILL.md and apply it to: [full plan]"

No limit on skill sub-agents. Spawn one for every skill that could possibly be relevant.

3. Discover and Apply Learnings/Solutions

LEARNINGS LOCATION - Check these exact folders:

knowledge-base/project/learnings/           <-- PRIMARY: Project-level learnings (created by soleur:compound)
├── performance-issues/
│   └── *.md
├── debugging-patterns/
│   └── *.md
├── configuration-fixes/
│   └── *.md
├── integration-issues/
│   └── *.md
├── deployment-issues/
│   └── *.md
└── [other-categories]/
    └── *.md

Step 1: Find ALL learning markdown files

Run these commands to get every learning file:

# PRIMARY LOCATION - Project learnings
find docs/solutions -name "*.md" -type f 2>/dev/null

# If docs/solutions doesn't exist, check alternate locations:
find .claude/docs -name "*.md" -type f 2>/dev/null
find ~/.claude/docs -name "*.md" -type f 2>/dev/null

Step 2: Read frontmatter of each learning to filter

Each learning file has YAML frontmatter with metadata. Read the first ~20 lines of each file to get:

---
title: "N+1 Query Fix for Briefs"
category: performance-issues
tags: [activerecord, n-plus-one, includes, eager-loading]
module: Briefs
symptom: "Slow page load, multiple queries in logs"
root_cause: "Missing includes on association"
---

For each .md file, quickly scan its frontmatter:

# Read first 20 lines of each learning (frontmatter + summary)
head -20 knowledge-base/project/learnings/**/*.md

Step 3: Filter - only spawn sub-agents for LIKELY relevant learnings

Compare each learning's frontmatter against the plan:

SKIP learnings that are clearly not applicable:

SPAWN sub-agents for learnings that MIGHT apply:

Step 4: Spawn sub-agents for filtered learnings

For each learning that passes the filter:

Task general-purpose: "
LEARNING FILE: [full path to .md file]

1. Read this learning file completely
2. This learning documents a previously solved problem

Check if this learning applies to this plan:

---
[full plan content]
---

If relevant:
- Explain specifically how it applies
- Quote the key insight or solution
- Suggest where/how to incorporate it

If NOT relevant after deeper analysis:
- Say 'Not applicable: [reason]'
"

Spawn sub-agents in PARALLEL for all filtered learnings.

These learnings are institutional knowledge - applying them prevents repeating past mistakes.

4. Launch Per-Section Research Agents

<thinking>

For each major section in the plan, spawn dedicated sub-agents to research improvements. Use the Explore agent type for open-ended research.

</thinking>

For each identified section, launch parallel research:

Task Explore: "Research best practices, patterns, and real-world examples for: [section topic].
Find:
- Industry standards and conventions
- Performance considerations
- Common pitfalls and how to avoid them
- Documentation and tutorials
Return concrete, actionable recommendations."

Also use Context7 MCP for framework documentation:

For any technologies/frameworks mentioned in the plan, query Context7:

mcp__plugin_soleur_context7__resolve-library-id: Find library ID for [framework]
mcp__plugin_soleur_context7__query-docs: Query documentation for specific patterns

Verify API availability against installed SDK version: Context7 docs may reference APIs not yet available in the project's pinned dependency version. After recommending a specific API (e.g., getClaims()), check node_modules or Gemfile.lock to confirm the method exists in the installed version before including it in the plan.

Use WebSearch for current best practices:

Search for recent (2024-2026) articles, blog posts, and documentation on topics in the plan.

4.4. Precedent-Diff Gate (Pattern-bound Behaviors)

When the plan section prescribes pattern-bound behaviors with sibling-precedent files in the same repo — (a) SQL function definitions with SECURITY DEFINER/INVOKER, (b) atomic write sequences (open/write/rename/fsync), (c) lock acquisition or mutex patterns, (d) RPC permissioning, (e) connection-pool tuning, (f) circuit-breaker shapes, or (g) any other shape where the codebase has established a canonical form — git grep for the precedent and produce a side-by-side diff in the plan's "Risks & Mitigations" section. If no precedent exists, the plan must explicitly note "no precedent; pattern is novel" so reviewers know to scrutinize. Why: PR #2954 — initial plan prescribed SECURITY INVOKER for a v1→v2 BYOK migration RPC; deepen-plan caught and corrected to SECURITY DEFINER via precedent migration 027. Same PR: atomic-write missing fdatasync between write and close; deepen-plan added it after grepping for prior atomic-write call sites. See knowledge-base/project/learnings/best-practices/2026-05-05-trace-callgraph-from-entrypoint-when-placing-guards.md. Plan-skill counterpart: precedent-diff is enforced at deepen-plan (forward-pointer).

Scheduled-work pattern check

When the plan introduces a new scheduled job (recurring task, cron, polling loop), check the canonical pattern BEFORE proposing the trigger mechanism. Run:

git ls-files | grep -E "apps/web-platform/server/inngest/functions/cron-" | head -3
git ls-files | grep -E "^\.github/workflows/scheduled-" | wc -l

If the Inngest cron functions count is > 0, propose the scheduled job as an Inngest function under apps/web-platform/server/inngest/functions/cron-*.ts — NOT as a .github/workflows/scheduled-*.yml workflow. The Inngest path is canonical per ADR-033.

GH Actions cron is acceptable ONLY when (a) the work is purely git/repo-scoped (no app context, no app secrets, no Sentry integration) AND (b) the work could not benefit from step.run memoization / Inngest replay. When in doubt, prefer Inngest.

Why: PR #4452 shipped scheduled-stale-deferred-scope-outs.yml as GH Actions cron and was immediately migrated to Inngest in PR #4457 because the work properly belongs in Inngest. The precedent-check at plan time would have caught this; the post-implementation review almost missed it. The .claude/hooks/new-scheduled-cron-prefer-inngest.sh PreToolUse hook is the mechanical second-net.

4.45. Round-1 Implementation-Realism Passes

After Phase 4 spawns per-section research agents, fan out two additional agent passes in the same parallel batch:

  1. Verify-the-negative pass. For every negative security claim in the plan body (regex: NEVER|MUST NOT|does not reach|cannot leak|is not exposed), spawn a targeted agent task: "grep the named/implied implementation file for the constrained behavior; report contradicts | confirms | not-applicable with file:line citation." This catches "the field is not exposed to clients" claims that contradict a process.env.NEXT_PUBLIC_* site one grep away.
  2. Post-edit self-audit pass. After round-1 edits drop or rename infrastructure (tables, columns, modules), spawn a re-read pass that greps the plan body for references to dropped symbols. Every hit is a candidate for a downstream rewrite that round 1 missed (e.g., tenant_cost_window ON CONFLICT after the table was dropped).

Tier advisory (ADR-053 / ADR-110): spawn both passes with semantic tier standard — they are pure grep sweeps with ternary verdicts (the most mechanical Task spawns in the plugin), so the session's top tier adds cost without recall. Per-section research agents and the merge pass stay on the session model.

Why: PR #3240 deepen-pass for feat-agent-runtime-platform showed two round-1 misses (BYOK process.env contradiction; tenant_cost_window ON CONFLICT after table-drop) that round 2 caught only because the user re-invoked the skill. Folding both passes into round 1 closes the loop without requiring a second user invocation. See knowledge-base/project/learnings/best-practices/2026-05-05-deepen-pass-round-2-implementation-realism-vs-round-1-structural.md.

4.5. Network-Outage Deep-Dive (Conditional)

If the plan's Overview, Problem Statement, or Hypotheses contain any of the trigger patterns SSH, connection reset, kex, firewall, unreachable, timeout, 502, 503, 504, handshake, EHOSTUNREACH, ECONNRESET (case-insensitive), read plugins/soleur/skills/plan/references/plan-network-outage-checklist.md and spawn a dedicated "Network-Outage Deep-Dive" research agent in parallel with the other deepen agents.

Resource-shape trigger (implicit SSH dependency). Also fire this gate when the plan drives terraform apply (with or without -target=) on any resource whose definition contains provisioner "file", provisioner "remote-exec", or a connection { type = "ssh" ... } block. The provisioner block makes SSH a hard apply-time dependency the prose-only keyword scan won't detect — the plan body need not mention SSH for apply to hit connection reset by peer on a drifted egress IP. Why: #3061 — plan body had zero SSH keywords; apply on terraform_data.deploy_pipeline_fix (file+remote-exec provisioners) still hit a handshake reset because Phase 4.5 didn't fire.

The deep-dive agent's task:

  1. Read the checklist in full.
  2. For each of the four layers (L3 firewall allow-list, L3 DNS/routing, L7 TLS/proxy if HTTPS, L7 application), verify the plan's Hypotheses section cites a concrete verification artifact (CLI output, log excerpt, or explicit "not verified" note).
  3. Emit a "Network-Outage Deep-Dive" subsection in the plan with the layer-by-layer verification status and any gaps that need closing before implementation.

Per AGENTS.md hr-ssh-diagnosis-verify-firewall, plans addressing SSH/network-connectivity symptoms MUST verify the L3 firewall allow-list against current client egress IP BEFORE proposing service-layer fixes. The deep-dive is the deepen-plan enforcement layer.

When a trigger pattern matches, emit rule-application telemetry so the weekly aggregator records the deepen-plan enforcement layer fired (see AGENTS.md hr-ssh-diagnosis-verify-firewall):

echo 'SOLEUR_RULE_APPLIED rule=hr-ssh-diagnosis-verify-firewall note=When a plan addresses an SSH/network-connectivity s'

4.55. Downtime & Cutover Halt — Zero-Downtime-First (Conditional)

Soleur users are a live single-operator surface; an unexpected outage of the web/Concierge platform is a single-user incident (brand-survival). So a plan whose change would take a serving surface offline MUST default to a zero-downtime cutover and prove it in the plan — not treat downtime as the baseline.

Trigger — fire when the plan's Files-to-Edit or Overview implies a downtime-inducing operation. Any of:

Rule. On trigger, the plan MUST contain a ## Downtime & Cutover section that (1) names the exact offline-inducing operation and the surface it affects, (2) evaluates a zero-downtime path — blue-green (provision the new resource fresh, drain, cut over, retire the old), rolling, expand-contract (add-nullable → backfill → enforce → drop-old), terraform state mv/state-only re-address, CREATE INDEX CONCURRENTLY, drain-then-act — and defaults to it, and (3) accepts residual downtime ONLY with an explicit justification + a bounded maintenance window + operator sign-off. HALT if the trigger fires and the section is absent or is boilerplate (no concrete cutover mechanism, no per-stage verification/rollback). This is the deepen-plan companion to Phase 4.6 (user-brand impact) and 4.5 (network-outage), scoped to availability during the change itself.

Emit telemetry when the gate fires (records the enforcement layer for the weekly aggregator, mirroring the sibling halts 4.5/4.6; reuses the brand-survival rule this gate invokes):

echo 'SOLEUR_RULE_APPLIED rule=hr-weigh-every-decision-against-target-user-impact note=Downtime & Cutover halt: plan must default to a zero-'

Why: #5887 — a moved-block migration was framed as a rebooting full terraform apply; the actual wedge cleared with a zero-downtime terraform state mv (state-only re-address, no reboot), and the real web-2 cutover is blue-green (a fresh host is born into the placement group with no reboot; only the old host needs a power-off, done while drained). The rebooting path was the default only because no gate forced a zero-downtime evaluation first. See knowledge-base/project/learnings/2026-07-02-zero-downtime-first-moved-block-statemv-and-blue-green-cutover.md.

4.6. User-Brand Impact Halt (Always)

Per AGENTS.md hr-weigh-every-decision-against-target-user-impact, every plan MUST contain a ## User-Brand Impact section before deepen-plan can proceed. This phase is a hard gate — no deepen agents fan out until the section exists and contains concrete content.

Step 1 — Locate the section. Grep the target plan file:

grep -q '^## User-Brand Impact' <plan-file>

If the heading is absent, HALT with:

Error: Plan is missing ## User-Brand Impact section.

See plan-issue-templates.md for the template.

Per AGENTS.md hr-weigh-every-decision-against-target-user-impact, every plan

must answer the user-impact framing question before deepen-plan can proceed.

Re-run soleur:plan (or edit the plan directly) to add the section, then re-run deepen-plan.

Step 2 — Validate the body. If the heading exists, extract the section body (everything between ^## User-Brand Impact and the next ^## heading). Reject the section as non-compliant if ANY of:

```bash

SENSITIVE_PATH_RE='^(apps/web-platform/(server|supabase|app/api|middleware\.ts$)|apps/web-platform/lib/(stripe|auth|byok|security-headers|csp|log-sanitize|safe-session|safe-return-to|supabase)|apps/web-platform/lib/(legal|auth)/|apps/[^/]+/infra/|.+/doppler[^/]\.(yml|yaml|sh)$|\.github/workflows/.(doppler|secret|token|deploy|release|version-bump|web-platform|infra-validation|cla|cf-token|linkedin-token).*\.ya?ml$)'

```

AND no threshold: none, reason: <one-sentence> scope-out bullet (with a non-empty reason) is present in the section.

On rejection, HALT with the same error message as Step 1, replacing the first line with the specific failure (empty body, placeholder content, missing threshold, none-threshold without scope-out).

Step 3 — Emit telemetry. When the halt fires (Step 1 OR Step 2), emit rule-application telemetry so the weekly aggregator records the deepen-plan enforcement layer fired:

echo 'SOLEUR_RULE_APPLIED rule=hr-weigh-every-decision-against-target-user-impact note=Every plan/PR touching credentials, auth, data, paym'

Step 4 — Pass-through. If the section is present, non-empty, has a valid threshold, and (when none) has a scope-out line for sensitive-path diffs, deepen-plan proceeds normally. No telemetry is emitted on pass — the gate only records when it activates.

Why: The framing layer (brainstorm Phase 0.1) and the template layer (plan Phase 2.6) can both be skipped or filled with placeholders. This phase is the load-bearing pre-implementation gate that catches both — a plan with an empty section cannot pass deepen-plan, which means it cannot proceed to soleur:work. Combined with preflight Check 6 (ship-time gate) and the soleur:engineering:review:user-impact-reviewer conditional agent (review-time gate), this closes the workflow loop introduced for #2887.

4.7. Observability Gate Verification (Always)

Per AGENTS.md hr-observability-as-plan-quality-gate, every plan whose Files-to-Edit touches production code/infra (per plan Phase 2.9 trigger set) MUST contain a ## Observability section with the 5-field schema. Symmetric to Phase 4.6 above; this gate is what makes plan Phase 2.9 load-bearing.

Step 1 — Detect trigger. Inspect the plan's ## Files to Edit (or equivalent) list. If every path matches one of:

then the plan is pure-docs — skip silently (no further checks).

Otherwise the gate applies; proceed to Step 2.

Step 2 — Locate the section. Grep the target plan file:

grep -q '^## Observability' <plan-file>

If absent, HALT with:

Error: Plan touches production code/infra but is missing ## Observability section.

See plan-issue-templates.md for the schema.

Per AGENTS.md hr-observability-as-plan-quality-gate, every plan that ships production

code or infrastructure must declare its observability surface before deepen-plan proceeds.

Step 3 — Validate field values. Extract the section body (between ^## Observability and the next ^## heading). For each of the 5 required top-level fields (liveness_signal, error_reporting, failure_modes, logs, discoverability_test), reject if ANY of: <!-- markdownlint-disable-line MD038 -->

Scope of the two #8412 conditions (cap, expected_output literal). They bind a

discoverability_test this run AUTHORS or AMENDS. Measured at introduction, ~372 of the 856 plans

under knowledge-base/project/plans/ carrying the block declare a prose or block-scalar

expected_output and ~261 a suite-shaped command, every one compliant when written — deepen-plan

exists to enhance exactly those files. Against a PRE-EXISTING block, report these two as findings

and PROCEED; HALT on them only when the block is new or edited in this same run. Every other reject

condition above halts either way. Canonical statement: plan/SKILL.md Phase 2.9.

On rejection, HALT with a message naming the specific field and its failure mode (e.g., "Phase 4.7 reject: liveness_signal is empty (no sub-fields and no inline value)").

Step 4 — Emit telemetry. When the halt fires (Step 2 OR Step 3), emit:

echo 'SOLEUR_RULE_APPLIED rule=hr-observability-as-plan-quality-gate note=Every plan touching production code/infra MUST declar'

Step 5 — Pass-through. If the section is present, all 5 fields exist with non-placeholder values, no field is empty, discoverability_test.command does not require SSH, starts with an allowlisted probe verb and can finish inside Check 10's 15-second cap, and discoverability_test.expected_output is a matchable literal rather than prose — or the block carries a non-placeholder credentials_required declaration — deepen-plan proceeds normally. No telemetry on pass.

Why: #4116 — inngest-heartbeat.service was silently broken for 16+ hours because the substrate (introduced in #4085) declared no observability surface and the operator never had a non-SSH way to verify the heartbeat. Combined with plan Phase 2.9 (template-time gate), this phase is the load-bearing pre-implementation gate. The empty-key reject was added per the PR #4123 review — the most common drift mode is liveness_signal: with no children, which earlier regex-only forms allowed through.

4.8. PAT-Shaped Variable Halt (Always)

Per AGENTS.md hr-github-app-auth-not-pat, plans that introduce or reference a PAT-shaped TF variable, env var, or literal-format token for infra-time GitHub writes MUST be halted at deepen-plan time. App auth (App ID + installation_id + PEM) supersedes PAT across the board — Apps don't expire, don't require per-operator minting, and survive operator handoff.

Step 1 — Trigger. Always runs. The detection only fires on match; no opt-out.

Step 2 — Grep the plan. Run the following regex sweep against the plan file (case-insensitive):

PLAN="<plan-file>"
HITS=$(grep -niE '\bvar\.(github_actions_token|github_token|gh_token|gh_pat|github_pat|actions_token|installation_token|repo_token)\b|\bTF_VAR_(GITHUB|GH)_(TOKEN|PAT|AUTH)\b|\bvar\.[a-z_]*_(pat|token)\b|\b(ghp_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9_]{82,})\b' "$PLAN" || true)

The four patterns target distinct PAT shapes:

Step 3 — HALT on match. If HITS is non-empty, emit:

Error: Plan references PAT-shaped variable or literal. Use GitHub App auth (App ID + installation_id + pem_file via the integrations/github provider's app_auth block) per AGENTS.md hr-github-app-auth-not-pat. The soleur-ai GitHub App (App ID 3261325) is provisioned and the discovery script is at apps/web-platform/infra/scripts/get-app-installation-id.sh. Apps don't expire, don't require per-operator minting, and survive operator handoff.

Matches:

$HITS

Halt deepen-plan; do NOT proceed to Phase 5.

Step 4 — Emit telemetry. When the halt fires, emit:

echo 'SOLEUR_RULE_APPLIED rule=hr-github-app-auth-not-pat note=Infra/CI GitHub writes auth via GitHub App, never PAT'

Step 5 — Pass-through. If no PAT-shaped patterns match, deepen-plan proceeds normally. No telemetry on pass.

Why: #4144 — PR-H #4066 added var.github_actions_token as a required TF variable, then never populated it in Doppler. Every Apply deploy-pipeline-fix.yml run since 2026-05-19T21:41Z failed before terraform plan could evaluate, blocking the entire deploy pipeline for ~14h (sudoers entry never refreshed → deploy webhook errored at sudo: deploy : command not allowed → Inngest heartbeat went silently red). The first defense is at plan-write time: catch PAT-shaped variables before they reach a workflow YAML.

4.9. UI-Wireframe Artifact Halt (Conditional)

Per wg-ui-feature-requires-pen-wireframe, a plan touching a UI surface must reference a committed .pen wireframe — otherwise the design phase silently shipped without one. This is the deepen-plan verifier on the one-shot path (one-shot chains plan→deepen-plan and skips brainstorm), mirroring the Phase 4.6/4.7 halts.

Step 1 — Trigger. Fires only when the plan touches a UI surface. Match the plan's ## Files to Edit and ## Files to Create against the shared UI-surface term list + glob superset (plugins/soleur/skills/brainstorm/references/ui-surface-terms.md). No UI-surface file → skip silently (pass-through).

Step 2 — Grep for a committed .pen reference. On a UI-surface plan, grep the plan body for a wireframe-artifact reference and confirm it is committed:

PLAN="<plan-file>"
PEN=$(grep -oE 'knowledge-base/product/design/[A-Za-z0-9/_-]+\.pen' "$PLAN" | sort -u || true)
COMMITTED=""
for p in $PEN; do git ls-files --error-unmatch "$p" >/dev/null 2>&1 && COMMITTED="$COMMITTED $p"; done

Step 3 — HALT on absence. If the plan touches a UI surface but COMMITTED is empty, emit:

Error: Plan touches a UI surface but references no committed .pen wireframe. Wireframes are a non-skippable deliverable (wg-ui-feature-requires-pen-wireframe) — run the producer (brainstorm Phase 3.55 or plan Phase 2.5; Pencil auto-installs via pencil-setup --auto), commit the .pen under knowledge-base/product/design/{domain}/, and reference it in the plan FRs. No Markdown/ASCII fallback.

Halt deepen-plan; do NOT proceed to Phase 5.

Step 4 — Emit telemetry. When the halt fires:

echo 'SOLEUR_RULE_APPLIED rule=wg-ui-feature-requires-pen-wireframe note=UI feature must ship a committed .pen wireframe, never skipped'

Step 5 — Pass-through. Non-UI plan, or .pen committed → proceed. No telemetry on pass. Why: #4819.

4.10. Encryption Posture Halt (Conditional)

Symmetric to Phase 4.7 above; this gate is what makes plan Phase 2.11 load-bearing. Fires only when the plan introduces a persistent data store or a new cross-component/network connection.

Step 1 — Trigger. Fires when the plan's ## Files to Edit / ## Files to Create match one of \.tf$, supabase/migrations/.*\.sql$, cloud-init.*\.ya?ml$, docker-compose.*\.ya?ml$, OR the plan prose names a store class (volume, database, bucket, queue, cache, backup target, log sink) or a new cross-component connection. No match → skip silently.

Step 2 — Locate the section. Grep the target plan file:

grep -q '^## Encryption Posture' <plan-file>

If absent, HALT with:

Error: Plan introduces a persistent store or cross-component connection but is missing ## Encryption Posture section.

See plan-issue-templates.md for the schema.

Every new store or connection must declare a design-time encryption posture before deepen-plan proceeds.

Step 3 — Validate field values. Extract the section body (between ^## Encryption Posture and the next ^## heading). For each at_rest entry (mechanism, evidence, defends_against, does_not_defend, disclosed_as, live_verification) and each in_transit entry (tls, cert_verification, does_not_defend, disclosed_as), reject if ANY of: <!-- markdownlint-disable-line MD038 -->

On rejection, HALT with a message naming the specific field and its failure mode (e.g., "Phase 4.10 reject: at_rest[0].does_not_defend is empty").

Step 4 — Emit telemetry. When the halt fires (Step 2 OR Step 3), emit:

echo 'SOLEUR_RULE_APPLIED rule=encryption-posture-design-time-default note=Every new store/connection MUST declare a verified encryption posture at plan time'

Step 5 — Pass-through. If the section is present, all required fields exist with non-boilerplate values, does_not_defend is non-empty, and every exception block carries both tracking_issue and expires_on, deepen-plan proceeds normally. No telemetry on pass.

Why: ADR-140 and knowledge-base/project/plans/archive/20261013-041741-2026-07-23-feat-encryption-posture-design-time-default-plan.md (Plan Review Revisions R1-R11). A declaration-only gate without Layer A (lint-encryption-posture.py, repo-root scripts/, resolving every citation against real code) and Layer B (live provider/host reconciliation) reproduces #6588 exactly — legal docs declared LUKS while the volume was plaintext ext4. This deepen-plan halt is the design-time half; it stops an underspecified or boilerplate posture from ever reaching soleur:work.

4.11. Guard Contract Halt (Conditional)

Fires when the plan's deliverable includes a guard, gate, lint, drift-check or anti-vacuity control (plan Phase 2.12). This is the design-time verifier that a guard-shaped plan carries a usable Guard Contract before soleur:work writes any guard code.

Step 1 — Detect. Scan the plan's ## Files to Create / ## Files to Edit and its prose for guard-shaped deliverables: a new repo-root lint-* script, a *.test.sh drift guard, a CI gate, a lifecycle.precondition, a hook, or prose naming a "guard"/"gate"/"drift-check". If none, SKIP silently.

Step 2 — Locate the section.

grep -q '^## Guard Contract' <plan-file>

Absent while detection fires → HALT with:

Error: Plan's deliverable includes a guard but there is no ## Guard Contract section.

See plan-issue-templates.md for the template.

Per plan Phase 2.12, each guard needs its property, its structural ASSEMBLY, and a

mutation matrix of >= 3 edits that must go RED. Re-run soleur:plan (or edit the plan

directly) to add the section, then re-run deepen-plan.

Step 3 — Resolve it mechanically. Do not re-implement the field checks in prose — run the gate that owns them:

python3 scripts/lint-guard-contract.py <plan-file>

Non-zero → HALT and surface the lint's own FAIL: lines verbatim. It rejects: a heading with zero ### Guard entries; a missing or placeholder **Property.** / **Assembly.**; a mutation matrix under 3 rows. It quantifies over EVERY entry, never the first.

Step 4 — Adequacy read (the part no lint can do). The lint proves the fields are present and non-empty; only a reader can judge whether the ASSEMBLY is structural. Reject and HALT when the Assembly enumerates the current MEMBERS (a list of today's mounts, today's call sites) rather than the STRUCTURE that produces them (the chokepoint they must flow through, the array that holds them, the walk that finds them). Members drift; assembly does not. Equally, reject a mutation matrix whose rows were plainly derived from a finished implementation rather than from the design — the tell is a row naming a specific variable or line that only exists because the code was written that way.

Step 5 — Pass-through. Section present, lint green, assembly structural → proceed normally. No telemetry on pass.

Why: the preflight Check 10 work (merged 2026-08-10) cost five adversarial review rounds and ~880k subagent tokens on ~20 findings that all reduced to one class — a guard's window/chokepoint/identifier set narrower than the property it named. The plan that produced it had 13 Test Scenarios all shaped "command X -> terminal Y" and none shaped "mutation M -> guard G reddens", so the guards were written as assertions about the implementation as it happened to be shaped. This halt is the independent verifier that the enumeration happened at design time rather than being discovered five times at review time.

4.12. Scope Check Halt (Always)

Fires on every plan — every plan has asks. This is the enforcement half of plan Phase 2.4 (plugins/soleur/skills/plan/references/plan-scope-check.md): a plan that never emitted its ## Scope Check, or emitted one with an unjustified row, cannot be deepened.

Step 1 — Detect. Always — no trigger scan.

Step 2 — Locate the section. Fenced ## Scope Check occurrences are schema examples, not the section — a bare grep is fence-blind. First confirm "$PLAN_FILE" exists and is readable (a missing path prints 0 identically — the halt then names the path, not the plan). Count unfenced occurrences:

awk 'BEGIN{f=0} /^[[:space:]]*```/{f=!f; next} !f' "$PLAN_FILE" | grep -c '^## Scope Check$'

Read the printed COUNT, not the exit code — grep -c exits 1 on 0, which is a verdict, not a command failure. 0 → absent → HALT; >1 → malformed → HALT ("plan carries N duplicate live ## Scope Check sections — keep one"). On 0, halt with:

Error: Plan has no compliant ## Scope Check section. Per plan Phase 2.4 every plan emits

one (see plugins/soleur/skills/plan/references/plan-scope-check.md; schema in

plan-issue-templates.md). Re-run soleur:plan or add the section by hand, then re-run.

Step 3 — Verify it mechanically. Reject and HALT (same message shape; first line names the failing row; recovery: fix it in the plan file, then re-run) when ANY of:

Step 4 — Adequacy read (the part no lint can do). Reject when the table is padding: justifications that are boilerplate ("needed", "required") naming no dependency or safety reason; asked rows quoting words the operator never wrote; a Split Assessment whose counts were not derived from the plan's ## Files to Edit/## Files to Create lists; an ask invented to match the plan rather than quoted from the brief. The brief's source: the plan's frontmatter issue: → gh issue view <N> --json body, or the freeform description the plan names.

Step 5 — Emit telemetry on fire. When the halt fires (Step 2, 3, OR 4), emit rule-application telemetry so the weekly aggregator records the enforcement event:

echo 'SOLEUR_RULE_APPLIED rule=plan-scope-check-blocks-unmapped-asks note=deepen-plan halted: plan missing/non-compliant Scope Check'

No telemetry on pass — the gate only records when it activates.

Step 6 — Pass-through. Compliant → proceed.

Why: #9398 — on PR #9339 a brief listing tasks a–f grew a destructive --attest rung nobody asked for; the catch cost an 11-seat review and ~8 CI cycles. The deepen halt is what makes "an unmapped item blocks the plan unless justified" load-bearing rather than advisory.

4.13. Task-Design Halt (Conditional)

Trigger + reject contract: plan/references/task-design-gate.md (Detection table, UNFENCED count). On trigger HALT "Phase 4.13 reject: <field/section> — <failure mode>"; emit SOLEUR_RULE_APPLIED rule=task-design-design-time-default note=Every new autonomous task MUST answer the six task-design questions at plan time; else pass silent. Why: #11015.

5. Discover and Run ALL Review Agents

<thinking>

Dynamically discover every available agent and run them ALL against the plan. Don't filter, don't skip, don't assume relevance. 40+ parallel agents is fine. Use everything available.

</thinking>

Step 1: Discover ALL available agents from ALL sources

# 1. Project-local agents (highest priority - project-specific)
find .claude/agents -name "*.md" 2>/dev/null

# 2. User's global agents (~/.claude/)
find ~/.claude/agents -name "*.md" 2>/dev/null

# 3. soleur plugin agents (all subdirectories)
find ~/.claude/plugins/cache/*/soleur/*/agents -name "*.md" 2>/dev/null

# 4. ALL other installed plugins - check every plugin for agents
find ~/.claude/plugins/cache -path "*/agents/*.md" 2>/dev/null

# 5. Check installed_plugins.json to find all plugin locations
cat ~/.claude/plugins/installed_plugins.json

# 6. For local plugins (isLocal: true), check their source directories
# Parse installed_plugins.json and find local plugin paths

Important: Check EVERY source. Include agents from:

For soleur plugin specifically:

Step 2: For each discovered agent, read its description

Read the first few lines of each agent file to understand what it reviews/analyzes.

Step 3: Launch ALL agents in parallel

For EVERY agent discovered, launch a Task in parallel:

Task [agent-name]: "Review this plan using your expertise. Apply all your checks and patterns. Plan content: [full plan content]"

CRITICAL RULES:

Step 4: Also discover and run research agents

Research agents (like soleur:engineering:research:best-practices-researcher, soleur:engineering:research:framework-docs-researcher, soleur:engineering:research:git-history-analyzer, soleur:engineering:research:repo-research-analyst) should also be run for relevant plan sections.

6. Wait for ALL Agents and Synthesize Everything

<thinking>

Wait for ALL parallel agents to complete - skills, research agents, review agents, everything. Then synthesize all findings into a comprehensive enhancement.

</thinking>

Collect outputs from ALL sources:

  1. Skill-based sub-agents - Each skill's full output (code examples, patterns, recommendations)
  2. Learnings/Solutions sub-agents - Relevant documented learnings from soleur:compound
  3. Research agents - Best practices, documentation, real-world examples
  4. Review agents - All feedback from every reviewer (architecture, security, performance, simplicity, etc.)
  5. Context7 queries - Framework documentation and patterns
  6. Web searches - Current best practices and articles

For each agent's findings, extract:

Deduplicate and prioritize:

7. Enhance Plan Sections

<thinking>

Merge research findings back into the plan, adding depth without changing the original structure.

</thinking>

Enhancement format for each section:

## [Original Section Title]

[Original content preserved]

### Research Insights

**Best Practices:**
- [Concrete recommendation 1]
- [Concrete recommendation 2]

**Performance Considerations:**
- [Optimization opportunity]
- [Benchmark or metric to target]

**Implementation Details:**

// Concrete code example from research


**Edge Cases:**

- [Edge case 1 and how to handle]
- [Edge case 2 and how to handle]

**References:**

- [Documentation URL 1]
- [Documentation URL 2]

8. Add Enhancement Summary

At the top of the plan, add a summary section:

## Enhancement Summary

**Deepened on:** [Date]
**Sections enhanced:** [Count]
**Research agents used:** [List]

### Key Improvements
1. [Major improvement 1]
2. [Major improvement 2]
3. [Major improvement 3]

### New Considerations Discovered
- [Important finding 1]
- [Important finding 2]

9. Update Plan File

Write the enhanced plan:

Output Format

Update the plan file in place (or if user requests a separate file, append -deepened after -plan, e.g., 2026-01-15-feat-auth-plan-deepened.md).

Quality Checks

Before finalizing:

Post-Enhancement Options

After writing the enhanced plan, use the AskUserQuestion tool to present these options:

Question: "Plan deepened at [plan_path]. What would you like to do next?"

Options:

  1. View diff - Show what was added/changed
  2. Run /plan_review - Get feedback from reviewers on enhanced plan
  3. Start soleur:work - Begin implementing this enhanced plan
  4. Deepen further - Run another round of research on specific sections
  5. Revert - Restore original plan (if backup exists)

Based on selection:

Example Enhancement

Before (from soleur:plan):

## Technical Approach

Use React Query for data fetching with optimistic updates.

After (from soleur:deepen-plan):

## Technical Approach

Use React Query for data fetching with optimistic updates.

### Research Insights

**Best Practices:**
- Configure `staleTime` and `cacheTime` based on data freshness requirements
- Use `queryKey` factories for consistent cache invalidation
- Implement error boundaries around query-dependent components

**Performance Considerations:**
- Enable `refetchOnWindowFocus: false` for stable data to reduce unnecessary requests
- Use `select` option to transform and memoize data at query level
- Consider `placeholderData` for instant perceived loading

**Implementation Details:**

// Recommended query configuration

const queryClient = new QueryClient({

defaultOptions: {

queries: {

staleTime: 5 * 60 * 1000, // 5 minutes

retry: 2,

refetchOnWindowFocus: false,

},

},

});


**Edge Cases:**

- Handle race conditions with `cancelQueries` on component unmount
- Implement retry logic for transient network failures
- Consider offline support with `persistQueryClient`

**References:**

- <https://tanstack.com/query/latest/docs/react/guides/optimistic-updates>
- <https://tkdodo.eu/blog/practical-react-query>
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.