Claude-skill-registry agentic-diffusion

install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/agentic-diffusion" ~/.claude/skills/majiayu000-claude-skill-registry-agentic-diffusion && rm -rf "$T"
manifest: skills/data/agentic-diffusion/SKILL.md
source content

Agentic Diffusion

A semantic diffusion model for code that replaces mathematical noise with logic noise. Instead of predicting the final code in one pass (zero-shot), this system iteratively predicts what is wrong and removes it.

The Ralph Wiggum Loop

The architecture relies on persistence rather than intelligence. Like Ralph Wiggum's "I'm Helping!" enthusiasm, the system achieves correctness through eager iteration, not perfect prediction.

Four Distinct Roles

RoleMetaphorResponsibility
OrchestratorThe AdultManages the loop, tracks state, ensures persistence
Generator (Ralph)"I'm Helping!"Creates noisy initial drafts - eager, complete, messy
CriticThe GradientIdentifies bugs and flaws WITHOUT writing code
RefinerThe DenoiserSurgically removes specific bugs from current state

The Denoising Process

┌─────────────────────────────────────────────────────────────────┐
│  Step 0: Orchestrator defines goal → File starts empty          │
│     ↓                                                           │
│  Step 1: Generator (Ralph) drafts initial noisy code            │
│     ↓                                                           │
│  Step 2: Critic identifies flaws → "Bug on line 45"             │
│     ↓                                                           │
│  Step 3: Refiner rewrites specific logic → Removes noise        │
│     ↓                                                           │
│  Step 4: Reality Check → Run code (Ground Truth)                │
│     ↓                                                           │
│  Step 5: Loop until Critic is silent AND tests pass             │
└─────────────────────────────────────────────────────────────────┘

Usage

Start a Diffusion Loop

diffusion start "<GOAL>" --output <FILE> --max-iterations N

Example:

diffusion start "Create a Snake game with keyboard controls and collision detection" --output snake.ts --max-iterations 20

Using Sub-Agents

The Orchestrator spawns specialized sub-agents for each phase:

// Generator Phase (Ralph)
sessions_spawn({
  task: "Generate initial code for: <GOAL>",
  label: "diffusion-generator",
  agentId: "ralph-generator"
})

// Critic Phase
sessions_spawn({
  task: "Critique this code for bugs (no fixes): <FILE>",
  label: "diffusion-critic", 
  agentId: "diffusion-critic"
})

// Refiner Phase
sessions_spawn({
  task: "Fix these specific issues: <ISSUES>",
  label: "diffusion-refiner",
  agentId: "diffusion-refiner"
})

Check Status

diffusion status

Stop the Loop

diffusion stop

Why This Beats Zero-Shot

ApproachMetaphorFailure Mode
Zero-ShotDrawing a map from memoryHallucinations become permanent
Agentic DiffusionTracing and erasing mistakesReality Check catches hallucinations

State Management

State persists to

$CLAWD_WORKSPACE/.diffusion/state.json
:

{
  "goal": "Create a Snake game",
  "output_path": "snake.ts",
  "iteration": 5,
  "max_iterations": 20,
  "phase": "critic",
  "history": [...]
}

Sub-Agents Required

This skill requires the following sub-agents in

$CLAWD_WORKSPACE/subagents/
:

  • ralph-generator.md
    - The eager code generator
  • diffusion-critic.md
    - The bug finder
  • diffusion-refiner.md
    - The surgical fixer

Cost Warning

Autonomous loops consume tokens. Each iteration runs 3-4 sub-agents. A 20-iteration loop can run 60+ sub-agent invocations. Use

--max-iterations
wisely. (Or YOLO, if you're brave enough!)

When to Use

  • Complex coding tasks needing iteration
  • User asks to "diffuse", "iterate until working", or "ralph loop"
  • Code needs multiple refinement passes
  • Building something from scratch that must work

Orchestrator Instructions

When orchestrating a diffusion loop:

  1. Initialize state - Set goal, output path, max iterations
  2. Spawn Generator - Let Ralph create the initial noisy draft
  3. Spawn Critic - Get structured feedback on issues
  4. Check convergence - If no issues, verify and complete
  5. Spawn Refiner - Fix identified issues surgically
  6. Loop - Increment iteration, repeat from step 2
  7. Terminate - When converged or max iterations reached

Always run verification (execute the code) before declaring convergence.