Copy-paste is the dirty secret behind most prompt workflows.
You spend 20 minutes crafting the perfect system prompt. You nail the role definition, the tone rules, the output format, the edge case constraints. Then tomorrow you open a fresh chat and type most of it again from scratch. Every time. Across every tool. For every project.
A developer on r/PromptEngineering just shipped a proof of concept that attacks this problem directly: a Python CLI for macros in LLM prompts.
What It Is
The author built a command-line tool that lets you define reusable prompt fragments and inject them into any prompt using short macro names. Think of it like keyboard shortcuts, except instead of pasting “Best regards, John” at the end of emails, you’re injecting 200-word context blocks into AI prompts.
You define the fragment once. Give it a short name. Call that name anywhere in any prompt. The CLI expands it before the text ever hits the model. A single macro can carry your full persona definition, your output formatting rules, your chain-of-thought instruction, whatever you find yourself retyping most often.
The Twist: Prompt Pre-Processing
Here’s the part that makes this more interesting than a simple snippet manager. The macros expand before the prompt reaches the LLM. That means no API wrapper, no new interface, no framework lock-in. You run the CLI, get expanded text, copy it, paste it wherever you want.
This is exactly how C preprocessors work. How Makefile templates work. Developers have been doing this kind of thing for 40 years in code. The author just brought that logic to prompt engineering.
The result is model-agnostic. Claude, GPT-4, Gemini, any local model. Doesn’t matter. The macro system doesn’t touch the API at all. Your macros are just text files sitting on your machine, and the CLI is just a substitution engine. Simple, portable, zero dependency on any provider staying stable.
🛠️ How the Workflow Looks
- Define a macro: write the prompt fragment you reuse constantly. A persona definition, a formatting instruction block, a chain-of-thought trigger.
- Give it a short name: something like
@analystor@format_rules - Write your prompt normally, dropping macro names where the full text should go
- Run it through the CLI to expand all macros into the full prompt text
- 📋 Copy the result and paste into your chat interface or API call
The whole thing stays in plain text files. No proprietary format, no database, nothing that breaks when the tool updates. You can version control your macro library with git, share it with teammates, and diff changes just like you would with any codebase.
Why This Pattern Is Bigger Than the Tool
The proof of concept itself is early stage. The author is upfront about that. But the mental model it encodes is genuinely useful.
Right now, most people treat prompts as one-off writes. You type something, it works, you never save it. Or you save it in a Notion page somewhere and copy-paste pieces when you remember them.
Macros push you toward treating prompt fragments as maintained components. You version them. You name them semantically. You update them in one place when your workflow changes, instead of hunting down every chat where you typed that role definition by hand.
That’s a real improvement in how most people manage their prompt library, even if the tooling is still rough around the edges. When you finally update your tone guidelines or tighten your output format rules, one edit propagates everywhere instead of existing as fifteen slightly different versions across your saved chats.
💡 Pro Tips if You Try This
- Start with your most-repeated fragment. Most people have a “tone and format” block they paste into 70% of their prompts. That’s your first macro.
- Name macros by what they do, not what they contain.
@brief_analyst_v2_finalis useless in three months.@strict_analytical_personastill makes sense on day 90. - Keep a log of what each macro contains and when it was last updated. Prompt drift is subtle and you’ll want a paper trail when outputs start changing.
- Think about nesting: can your macros reference other macros? That’s where this pattern gets genuinely powerful, basically component libraries for prompts. A top-level
@research_modemacro could pull in your persona, your sourcing rules, and your output format all at once.
How It Compares
If you’ve used LangChain’s prompt templates, you’ll recognize the concept immediately. But LangChain does a lot more than this and that’s not always what you want. This proof of concept strips it down to the single most useful feature with zero framework overhead.
PromptLayer and similar tools track and version prompts too, but they’re API-level wrappers. This one operates before the API call and works with any interface, including the chat UI on Claude.ai or ChatGPT. No account needed, no API key required, no data leaving your machine until you decide to paste the result somewhere.
The full write-up with code examples is on Medium via the original Reddit post. If you’re building a serious prompt library, it’s worth 5 minutes to see where this idea could go. 🔗