MuseMuse Code Hub

Muse Prompts: 25 Patterns That Ship Working Code

Good Muse prompts are not luck — they are engineering. After running hundreds of prompts through Muse Code, the same patterns keep separating code that runs from code that only looks right. This guide distills what actually works into five principles, a reusable prompt skeleton, 25 copy-ready prompt patterns organized by scenario, bad-vs-good comparisons with runnable Python, and the context tricks that make Muse Code dramatically more reliable.

The 5 principles of Muse prompt engineering

Every pattern below is an application of these five principles. Internalize them and you can improvise prompts for situations no template covers.

1. State the outcome, not the method. Say what the finished artifact must do and let Muse Code choose the implementation — unless you have a real reason to dictate the method.

2. Constrain the solution space. Name the language version, allowed libraries, and style rules — plus what is forbidden (“no new dependencies”). An unconstrained model guesses; a constrained one engineers.

3. Show one example of the shape you want. A single input/output pair communicates more than three paragraphs of prose. Models continue patterns far better than they infer them from description.

4. Define “done”. Acceptance criteria turn a conversation into a contract: which edge cases must pass, what empty input returns, how you will verify.

5. Iterate in small loops. Prompt, run, paste the failure back. The model improves fastest on real errors, not imagined ones.

Anatomy of a high-signal prompt

Most strong Muse prompt examples share the same skeleton. Memorize it and fill in the blanks:

Context:  [what this code is for, the stack, where this file lives]
Task:     [one concrete deliverable, stated as an outcome]
Constraints: [versions, libraries, style, forbidden approaches]
Example:  [one input -> expected output pair]
Done when: [how you will verify: tests, edge cases, manual check]

You do not need all five blocks every time. A quick question needs only Task and Context; a gnarly refactor needs all five. The skeleton is a checklist, not a form — run through it mentally before you hit send and add whichever blocks are missing.

The 25 prompt patterns

Grouped by scenario. Each pattern is a reusable move — steal the wording, adapt the specifics.

Scoping and planning

  1. 1. The Contract — scope before code. Ask for a plan, file list, and function signatures before anything is written. Propose a plan first: files to touch, new function signatures, edge cases. Wait for my approval.
  2. 2. The Constraint Sandwich — fence both ends. State what is allowed and banned in one breath. Standard library only. No new dependencies, no recursion.
  3. 3. The Tiny Step — decompose the monster. Split one scary task into small sequential prompts. Step 1 of 4: write only the data loader. I will ask for step 2 next.
  4. 4. The Spike — prototype, then productionize. Get the ugliest working version first to validate the approach, then harden it together.

Code generation

  1. 5. Signature-First — design the interface. Nail down name, typed parameters, return type, and exceptions before the body exists. No implementation yet.
  2. 6. Example-Driven — lead with I/O. Give two or three input/output pairs and let the model infer the rule. slugify("Hello World!") -> "hello-world"
  3. 7. Skeleton Plus Fill — you architect, it builds. Write the structure with TODO markers; Muse fills each one without changing the structure.
  4. 8. Port, Don’t Rewrite — translate between languages. Hand over working code and ask for an idiomatic port. Port this JavaScript to idiomatic Python, not a line-by-line translation.
  5. 9. Config, Not Code — ask for the boring artifact. Stop hand-writing YAML, SQL migrations, and regexes — request them directly.

Debugging

  1. 10. Traceback Plus Context — the full crime scene. Paste the complete error with the code, the input, and what you expected. Diagnose first, then fix.
  2. 11. Minimal Repro — shrink the mystery. Ask the model to reduce the failing case to the smallest input that still triggers the bug.
  3. 12. Rubber-Duck Diagnosis — explain before fixing. Do not fix anything yet. Explain in plain language why this produces the wrong output.
  4. 13. Bisect the Blame — narrow the suspect list. When several changes could be guilty: Tell me the cheapest experiment to identify which change broke it.
  5. 14. Fix Forward With a Test — never fix alone. Every fix ships with a regression test that fails on the old code and passes on the new.

Refactoring

  1. 15. Behavior-Locked Refactor — change shape, not behavior. Refactor for readability only. Same inputs, same outputs, same exceptions.
  2. 16. Name Things Better — the cheapest refactor. A naming-only pass: Rename so each name describes what the thing does, not how. No logic changes.
  3. 17. Extract and Name — find the hidden functions. Find blocks that represent a single concept, extract each into a named function, show before/after.
  4. 18. Delete With Proof — prune dead code safely. For each apparently unused function, cite evidence — no callers, no imports — before deleting.

Explaining and documenting

  1. 19. Explain Like I’m New — calibrate the audience. Explain decorators as if I know basic Python but have never used one. Use one analogy.
  2. 20. The Guided Tour — orient in a new codebase. Map this repo: what each top-level directory does, where requests enter, where business logic lives.
  3. 21. Docstring Blitz — document in one pass. Add Google-style docstrings to every public function: parameters, return values, raised exceptions.
  4. 22. README From Code — derive docs from reality. Write a README based only on what the code does, so it cannot drift from reality.

Testing and review

  1. 23. Test the Contract — tests from the spec. Write pytest tests: normal input, empty input, None, and inputs that should raise. One test per case.
  2. 24. Adversarial Review — hire a hostile senior. Review like a hostile senior engineer. Cite file, line, and why it is wrong.
  3. 25. Regression Guard — lock today’s behavior. Before risky changes: Write characterization tests capturing this module’s current behavior exactly — bugs included.

Bad vs good: a runnable comparison

Theory is cheap. Here is the same task — parse a CSV of signups and count users per country — given to Muse Code twice. First the bad prompt:

Bad promptGood prompt
“Write Python code to parse a CSV and count users by country.”“Write a Python 3.12 script using only the standard library. Read signups.csv (columns: email, country, created_at). Print the top 10 countries by user count as COUNTRY: COUNT lines. Skip rows with a missing or blank country, and never crash on malformed rows — log them to stderr and continue. Done when: it handles a 1M-row file without loading it all into memory.”

The bad prompt returns a five-liner that loads everything into memory and dies on the first malformed row. The good prompt returns runnable code like this:

import csv
import sys
from collections import Counter

def count_by_country(path):
    counts = Counter()
    with open(path, newline="", encoding="utf-8") as f:
        for lineno, row in enumerate(csv.DictReader(f), start=2):
            try:
                country = (row.get("country") or "").strip()
                if not country:
                    continue
                counts[country] += 1
            except Exception as exc:
                print(f"skipping row {lineno}: {exc}", file=sys.stderr)
    return counts

if __name__ == "__main__":
    for country, n in count_by_country("signups.csv").most_common(10):
        print(f"{country}: {n}")

Notice what the constraints bought: streaming instead of loading, a defined malformed-row policy, and a verifiable performance requirement. None of that came from the model being “smart” — it came from the prompt doing the engineering.

Context tricks that multiply reliability

The best Muse prompts are rarely clever; they are well-supplied. Five supply runs that pay off every time:

Already have a Muse invite code? Get all 30 slots filled — tracked live.

Fill My Code

7 anti-patterns to unlearn

These habits silently degrade every prompt they touch:

  1. Vague verbs. “Handle”, “process”, “manage” specify no action. Use concrete verbs: parse, validate, sort, deduplicate, retry.
  2. No acceptance criteria. If you cannot say how you will verify the answer, the model cannot aim at it.
  3. The kitchen sink. One prompt, five unrelated questions. Split them — each answer improves when the prompt has a single job.
  4. The context dump. Pasting 2,000 lines with “fix it” and no pointer. Point at the suspect region and describe the symptom.
  5. “Make it better” with no metric. Better how — faster, shorter, more readable? Name the dimension or accept random motion.
  6. Accepting the first draft. The first answer is a starting bid. Follow-ups like “now handle the empty-input case” are where quality is built.
  7. Debugging by vibes. Describing the bug from memory instead of pasting the repro and traceback. Evidence in, accuracy out.

A repeatable prompting workflow

Put it all together as a loop for any task:

  1. Scope with The Contract (pattern 1) — plan before code.
  2. Constrain with the skeleton — versions, libraries, forbidden approaches, one example.
  3. Generate one small piece at a time (pattern 3), running each before moving on.
  4. Verify against your acceptance criteria; paste failures back raw (pattern 10).
  5. Harden with Adversarial Review (24) and Regression Guard (25) once it works.

Run this loop for a week and prompting stops feeling like coaxing an oracle — it feels like operating a very fast, very literal junior engineer. The people who get the most out of Muse prompt engineering are not the ones with the cleverest one-liners; they are the ones with the tightest loops.

Frequently Asked Questions

What are the best Muse prompts for beginners?

Start with three patterns from this guide: The Contract (ask for a plan before code), Example-Driven (give input/output pairs), and Traceback Plus Context (paste the full error with the code). These three alone fix the majority of beginner failures, which come from underspecified tasks rather than model limitations.

How long should a Muse prompt be?

As long as the task needs and not a word longer. A quick factual question can be one sentence. A code generation task usually needs 5 to 10 lines covering context, the task, constraints, one example, and acceptance criteria. Length is not the goal; removing ambiguity is.

Does Muse Code remember conversation context?

Yes, within a single conversation it remembers what you discussed, including constraints and earlier decisions. But context degrades over very long threads, so restate the critical constraints when you start a new thread or return to a topic after many messages.

Can I use these prompt patterns with other AI coding tools?

Almost all of them transfer directly. The patterns are about how you specify work to a language model - scoping, constraining, giving examples, verifying - not about Muse-specific features. Only product-specific details like where to paste a traceback need adjusting.

Why does Muse Code sometimes ignore my constraints?

Usually because the constraint was buried at the end of a long prompt or contradicted by the example you gave. Put hard constraints early in the prompt, repeat the single most important one, and make sure your example output actually obeys them. Models follow patterns more faithfully than prose instructions.

How do I get better at prompt engineering quickly?

Run tight loops: prompt, run the result, paste the failure back. Keep a small journal of prompts that worked well so you can reuse the structure. Within two weeks of deliberate practice, the five-part skeleton in this guide becomes automatic.