code-and-llm-collaborationlisted
Install: claude install-skill shimo4228/code-and-llm-collaboration
# Code and LLM Collaboration
When building a pipeline that mixes semantic work (summarization, classification, extraction) with structural work (validation, filtering, dispatch), the interesting question is **not** "which one should I use?" It is **"in what order, and with what contract between the layers?"**
Code and LLMs work best as layers, each doing the job the other cannot:
- Code is deterministic, cheap, and auditable but cannot understand meaning.
- LLMs handle meaning but are slow, probabilistic, and attackable.
Four layering patterns cover most real pipelines. Each has a characteristic failure mode when layers are skipped or reversed. Recognize which pattern you need, wire it in the correct order, and keep the contract between layers strict.
---
## Pattern 1 — LLM → Code guard
**Shape.** The LLM produces structured output. A code layer validates that output against a schema and enforces constraints before anything downstream consumes it. If validation fails, the pipeline rejects or retries — it does not pass partial output forward.
**When to use.**
- Any time LLM output will be written to a persistent store (database, knowledge file, identity document)
- Any time LLM output will be executed as structured data (tool-call arguments, JSON config, API payload)
- Any time the LLM is allowed to propose changes that a human will review — the guard prevents a human from rubber-stamping an invalid proposal
**Key insight.** The LLM is allowed to be wrong. The guard