C.W.K.
Stream
Lesson 02 of 04 · published

Where the Selection Goes

~10 min · input-token, template, rendering, append

Level 0Cold Flint
0 XP0/34 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"The template is the whole behavior. Rendering just drops your words into the hole marked {input}."

The Template Is the Behavior

A macro's behavior is entirely its prompt template — a short instruction with a slot. 'Fix the spelling and grammar; return only the corrected text.' 'Translate to Korean.' 'Rewrite this in a warmer tone.' The difference between a typo-fixer and a translator is one string. That's the beauty of the model: to make a new transformation, you write a new instruction, not new code. The macro is the prompt, and the prompt is text.

Dropping In the Selection

Rendering is the simplest possible operation: find {input} in the template and substitute the captured selection for it. A template like Fix the grammar:\n\n{input} becomes the instruction followed by your actual text. There's no parsing, no logic, no conditionals — just a string with a hole and the selection going into the hole. Keeping rendering this dumb is what keeps the macro a pure description: all the intelligence is downstream, in the brain, not in how the prompt gets assembled.

When the Template Has No {input}

Some macros don't put the selection in the middle — they're a standing instruction that the input should follow. The general-purpose 'Prompt' macro is like this: its template is an open instruction, and whatever you selected (or typed) is appended after a blank line rather than substituted into a slot. So the rule has two branches: if the template contains {input}, substitute there; if it doesn't, append the input after a blank line. Both produce a finished prompt; neither requires the template author to think about mechanics.

TEMPLATE WITH {input}:
  "Fix the grammar:\n\n{input}"   +  sel="teh cat"
  -> "Fix the grammar:\n\nteh cat"

TEMPLATE WITHOUT {input}:
  "Summarize the following."       +  sel="long text..."
  -> "Summarize the following.\n\nlong text..."   (appended)
Keep the client's rendering dumb so the intelligence stays in one place. The temptation is to make rendering clever — conditionals, helpers, mini-logic in the template. Resist it: the more logic lives in how the prompt is built, the more the client is quietly doing the thinking. A macro that is just 'instruction plus a slot' keeps a clean split — the client assembles text mechanically, and every ounce of judgment happens in the brain that reads it.

Code

Render: substitute {input}, or append if it's absent·swift
func render(_ template: String, input: String) -> String {
    if template.contains("{input}") {
        return template.replacingOccurrences(of: "{input}", with: input)
    }
    // No slot: the input follows the standing instruction after a blank line.
    return input.isEmpty ? template : "\(template)\n\n\(input)"
}

// Examples:
//   render("Translate to Korean:\n\n{input}", input: "hello")
//     -> "Translate to Korean:\n\nhello"
//   render("Summarize the following.", input: "long text")
//     -> "Summarize the following.\n\nlong text"

External links

Exercise

Write templates for three macros — a JSON formatter, an English-to-Korean translator, and a 'make this more concise' rewriter — deciding for each whether it uses an explicit {input} slot or relies on the append behavior. Then argue why rendering should stay a dumb substitution instead of, say, letting templates include conditional logic like 'if the text is code, wrap it in a fence.'
Hint
All three can use {input} for clarity, or the concise-rewriter could be a no-slot standing instruction with append — both are valid. Rendering must stay dumb because the moment a template can branch ('if code, then...'), the client is making judgments about the content, which is the brain's job. Push that decision into the instruction itself ('if the text is code, wrap it in a fence') and let the model decide — the client only ever assembles, never reasons.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.