{"slug": "sparkle-pills", "title": "Sparkle Pills", "summary": "GitHub Next published a post titled \"Sparkle Pills\" describing a templating convention in which instructions wrapped in `*(...)` mark slots that a large language model fills in while surrounding verbatim text is preserved by deterministic code. The pattern supports named slots, constraints such as `*(/^\\d{2}-\\d{2}-\\d{4}$/ the day of the party)`, option sets like `*({red, orange, yellow})`, and fill phases including write-time `*(...)`, compile-time `*[...]`, and run-time `*{...}`. The post argues the deterministic code owns the outer loop and replaces only the slots, so verbatim text is preserved and not paid for in output tokens.", "body_md": "# Sparkle Pills\n\nA flexible templating convention for contextual inference\n\nHere’s a little pattern I find handy for writing documents with AI when you already have a lot of text you want to preserve verbatim and a few slots where you want to generate something. I call these slots sparkle pills: instructions wrapped in `*(...)` that a model fills in.\n\nTry this prompt to get started:\n\n```\nRead https://githubnext.com/posts/sparkle-pills/ and build me a system for using sparkle pills. Interview me about my use case first.\n```\n\n## How it works\n\n```\nDear *(person's first name, or however they usually refer to themselves),\n\nIt's time for your annual security training! As a *(person's role), *(describe how security is relevant to their job duties). We're relying on you to help keep *(company name) safe.\n\nEveryone in *(person's department) is required to complete this training by *(due date).\n```\n\nYou could just give this template to an LLM in a prompt, along with the relevant context, and it would probably do a pretty good job. But if you want to ensure that none of your verbatim text gets altered, put deterministic code in charge. Have a script generate a prompt asking an LLM to return only an array of values to fill the sparkle pill slots.\n\n## Constraints and generation\n\nYou could use named slots like `*(role=the employee's role)` and ask for an object back, supplying a schema for structured output so you get the shape you need. You can refer to other slots from within a slot: `*(years of experience required for $role)`.\n\nYou can include constraints in your template slots, like `*(/^\\d{2}-\\d{2}-\\d{4}$/ the day of the party)`, and build those into your structured output schema. You can provide a limited set of options like `*({red, orange, yellow})` and encode that in the schema too.\n\nYou can have the LLM generate the entire set of template values at once. If the values don’t need to be consistent with one another, you can request them individually and in parallel.\n\nYou could include a cron expression, `*(*/5 * * * * tell me a joke)`, and use it to periodically update blocks on a website.\n\nYou can use this to plop down pseudocode to be rewritten while you continue with the rest of the program:\n\n``` js\nvar cart = *(some collection of test items)\nvar totalCost = cart.reduce(*(sum up the item.cost, I forget how to do this))\n```\n\n## When to fill the slots\n\nSparkle pills can be filled in at different phases of work, using different notations:\n\n- Write-time: `*(...)` gets processed while you are authoring the document, such as when you are drafting an issue.\n- Compile-time: `*[...]` gets subbed in when you compile or save code, or take an analogous step like submitting an issue.\n- Run-time: `*{...}` is for slots that persist in a saved document and get filled in later, like in an issue template or a mail-merge scenario.\n- Whatever-time: `*<>` or`*///...///` or whatever you want gets handled at whatever juncture makes sense in your system.\n\n## Build your own\n\nIt’s hyper-contextual and super-flexible. Your coding agent can help you design a system that works for your scenario.\n\nJust remember, the deterministic code owns the outer loop and replaces only the slots, so your verbatim text is preserved and you don’t have to pay for it in output tokens.", "url": "https://wpnews.pro/news/sparkle-pills", "canonical_source": "https://githubnext.com/posts/sparkle-pills/", "published_at": "2026-09-18 00:00:00+00:00", "updated_at": "2026-09-18 18:55:10.481725+00:00", "lang": "en", "topics": ["large-language-models", "ai-tools", "structured-data", "developer-tools"], "entities": ["GitHub Next"], "alternates": {"html": "https://wpnews.pro/news/sparkle-pills", "markdown": "https://wpnews.pro/news/sparkle-pills.md", "text": "https://wpnews.pro/news/sparkle-pills.txt", "jsonld": "https://wpnews.pro/news/sparkle-pills.jsonld"}}