Skip to content

Instantly share code, notes, and snippets.

@mpalpha
Created April 20, 2026 17:07
Show Gist options
  • Select an option

  • Save mpalpha/2824a441fb0dba1038f5099e695886f0 to your computer and use it in GitHub Desktop.

Select an option

Save mpalpha/2824a441fb0dba1038f5099e695886f0 to your computer and use it in GitHub Desktop.
Claude Code setup prompt for reusable workflow pattern learning, safe CLAUDE.md merging, and intelligent promotion of patterns into skills and subagents without clutter.

You are setting up a lightweight reusable workflow system for Claude Code. Follow these steps exactly.

Goal

Implement a simple, maintainable system that:

  • Routes large non-domain tasks through general-purpose
  • Tracks reusable task patterns
  • Promotes stable patterns into skills or subagents
  • Avoids file clutter and duplication
  • Preserves existing valid project instructions

Step -1 — Analyze and Plan (Required)

Before making any changes:

  1. Analyze the current project for:

    • existing CLAUDE.md
    • .claude/agents/, .claude/skills/, .claude/rules/
    • any existing workflow, routing, or automation patterns
  2. Identify:

    • what already exists
    • what overlaps with this system
    • what can be reused vs needs modification
  3. Produce a short plan:

    • what will be created
    • what will be updated
    • what will be merged
    • what will be left unchanged

Do not begin implementation until this plan is complete.

Do not proceed if the plan would:

  • duplicate existing structures
  • overwrite important instructions
  • create unnecessary new files

Step 0 — Bootstrap from Prior Chat History (Required if Available)

If prior Claude chat history is available, you MUST perform a one-time review during setup to identify repeated successful task patterns.

Only capture patterns that are clearly reusable. Do not copy full prompts or one-off tasks. Convert valid patterns into initial entries in .claude/task-pattern-registry.md.

If no prior chat history is available, skip this step.

After bootstrap, do not rely on chat history. The registry becomes the source of truth.


Step 1 — Safely Merge Existing CLAUDE.md (Required)

If CLAUDE.md already exists:

  1. Read the entire file first.

  2. Identify instructions related to:

    • task routing
    • subagent usage
    • reusable workflows
    • promotion or tracking logic
  3. Preserve all unrelated valid instructions.

  4. For overlapping instructions:

    • keep more specific instructions if compatible
    • merge compatible guidance
    • replace only directly conflicting parts
  5. Do not remove any instruction unless it is clearly:

    • duplicated
    • contradictory
    • obsolete due to this system
  6. Ensure this system becomes the single source of truth only for:

    • non-domain task routing
    • reusable workflow tracking
    • promotion into skills and subagents
  7. Keep CLAUDE.md concise (target under ~200 lines)

  8. Do not store examples, logs, or pattern data in CLAUDE.md

Before finalizing changes, produce a merge audit:

  • Kept unchanged:
  • Merged:
  • Replaced:
  • Removed:

Do not finalize if any removed instruction is not clearly justified.


Step 2 — Create or Update CLAUDE.md

Ensure CLAUDE.md contains:

Reusable Workflow Promotion

Use an existing domain subagent or skill whenever the task clearly matches one.

For large non-domain tasks (multi-step, multi-file, or likely high tool usage), use general-purpose with an inline prompt that includes:

  • objective
  • likely affected files
  • expected result
  • constraints

Do not use a subagent for small non-domain tasks.

When using general-purpose:

  • write the prompt inline
  • do not route through a manager subagent

After a successful large task, record only reusable patterns in one project registry. Do not log one-off prompts.

Promote a pattern only when all are true:

  • success count ≥ 2
  • task shape is materially the same across uses
  • prompt skeleton remains mostly stable
  • no existing skill or subagent already covers it

When promoting:

  • MUST check for an existing skill or subagent before creating a new one
  • update existing if overlap exists
  • create new only if clearly distinct

Promotion target:

  • Skill → repeatable procedure or checklist
  • Subagent → reusable delegated specialist role

Keep CLAUDE.md limited to routing and promotion policy only.


Step 3 — Create Registry File

Create: .claude/task-pattern-registry.md

Add:

Task Pattern Registry

Track only reusable, repeatable patterns. Do not store one-off tasks.

Template

  • name:
  • task type:
  • domain guess:
  • prompt skeleton:
  • key files:
  • success count:
  • last used:
  • stability note:
  • target (skill or subagent):

Rules:

  • Match existing entries before creating new ones
  • Update success count instead of duplicating entries

Step 4 — Ensure Structure

Ensure these folders exist:

.claude/agents/ .claude/skills/


Step 5 — Promotion Rules

When completing a large task:

  1. Determine if the pattern is reusable
  2. If yes, update or create a registry entry
  3. Do NOT store full prompts, only skeletons

Only promote when:

  • success count ≥ 2
  • pattern is consistent
  • prompt is stable

When promoting:

  • Prefer updating existing skills/subagents
  • Use clear, consistent names (short, descriptive, domain-based)
  • For subagents, include a clear “when to use” description

Step 6 — Cleanup and Maintenance

To prevent clutter:

  • Merge similar patterns
  • Remove or ignore rarely reused patterns
  • Merge or remove redundant skills/subagents
  • Prefer expanding existing ones over adding new ones

Step 7 — Constraints

  • Do not rely on chat history after bootstrap
  • Do not create many files for patterns
  • Do not promote unstable or one-off patterns
  • Keep everything minimal and maintainable

Result

The system should:

  • Learn from repeated successful work
  • Gradually produce high-quality reusable skills and subagents
  • Stay simple (single registry, minimal files)
  • Avoid duplication and long-term clutter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment