← ClaudeAtlas

when-code-when-llmlisted

Decision framework for choosing between deterministic code (regex, keyword match, AST parse, schema validation) and LLM-based processing (classification, semantic similarity, judge) for a single task. Use when you catch yourself writing a regex for a task that keeps producing false positives or negatives, or when you are about to call an LLM for something a three-line code check would handle. Covers the structural-vs-semantic axis, the false-positive test, worked examples of both directions, and the enumerate/decide split for tasks where detection is structural but resolution needs judgment.
shimo4228/when-code-when-llm · ★ 1 · AI & Automation · score 80
Install: claude install-skill shimo4228/when-code-when-llm
# When Code, When LLM Code and LLMs are not in opposition. They are different tools for different kinds of work, and the failure mode is not "picking the wrong side of a debate" — it is **forcing one tool to do the other's job.** Two symmetric failure modes to watch for: - **Code-where-LLM-belongs.** You write a regex to classify whether a paragraph is a test or a bug report. You add patterns. You add exceptions. The regex grows and still misclassifies. The task is semantic; no amount of pattern polish will fix it. - **LLM-where-code-belongs.** You call an LLM to "check if this filename ends in `.py`" or "validate this JSON." You pay latency, tokens, and nondeterminism for a check `str.endswith` would do in a nanosecond. This skill is the decision rule for telling them apart, plus examples of each kind going right and wrong. --- ## The judgment axis: structural vs semantic The question is not "is this task hard?" It is **"what kind of property am I checking?"** ### Structural properties — use code A property is structural when it depends only on the literal shape of the input: characters, tokens, delimiters, syntax, format. A machine reading the bytes can decide it without knowing what the text "means." Tools for structural work: - **Regex** — pattern presence, tag stripping, token replacement, format matching - **Keyword / substring match** — `in`, `startswith`, `endswith` - **AST / parser** — "does this Python file define a class named `Foo`?" - **Schema validati