prompt-crafter
Skill1 starsChanged 3 months agoUnlicenseView on GitHub
Craft effective prompts for AI coding tasks by applying research-backed principles that prevent cargo-cult copying, reduce hallucination, and improve code quality. Use when writing prompts for subagents, planning tasks for AI coding tools, or structuring instructions that reference existing code as exemplars.
In this repository5 other files it gives its agents.
- adversarial-reviewerSkill
- delegation-coachSkill
- feature-reportSkill
- githubSkill
- review-readySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 11 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Use delegation-coach first when:
- Very specific: line 36
If these are not available, ask for them or recommend using delegation-coach first.
- Distinctive: line 62
When you tell an AI coding agent "follow the existing pattern," it copies EVERYTHING — including the wrong things.
- Distinctive: line 74
The #1 intervention: Remove decorative patterns from the code the model will read before worrying about prompt wording.
- Distinctive: line 86
Import statements for utilities the new task doesn't need
- Distinctive: line 128
Instead of inoculation, clean the exemplar: If you can't clean it, use targeted reference instructions (Principle 2) rather than negative …
- Distinctive: line 192
Implication: If your codebase conventions live in decorators, they are maximally cargo-prone.
- Distinctive: line 204
When the pattern is semantically rich (retry logic, not a decorator), models sometimes produce conscious rejections — explicit comments …
- Distinctive: line 216
Implication: If your prompt asks the model to "follow patterns" and the output has no commentary about pattern choices, the model may be …
- Distinctive: line 222
When you can't clean the exemplar, provide a pre-built skeleton for the target file.
- Distinctive: line 262
If the model was already clean, the review is redundant.
- Distinctive: line 299
Implication: Before investing time in prompt engineering, first decide:
- Distinctive: line 407
When reviewing a prompt before sending it to an AI coding agent:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Prompt Crafter
Description
Craft effective prompts for AI coding tasks using principles derived from cargo-cult coding experiments. These experiments tested how AI models copy patterns from exemplar files and identified what makes prompts safe or dangerous.
The core finding: your exemplar files are a steering input, and model choice affects how cleanly the model responds to that steering. Later Musa experiments showed that stronger models still help, but they do not make exemplar steering disappear on medium, architecture-sensitive tasks.
Recommended workflow
Use delegation-coach first when:
- task type is unclear
- workflow choice is unclear
- exemplar risk is unclear
- you are not sure whether to scaffold or review
- you are deciding between productive work and experiment mode
Then use prompt-crafter to turn that framing into an execution-ready prompt.
Best inputs for this skill
prompt-crafter works best when given:
- task class
- target workflow
- exemplar guidance
- constraints
- validation command
- review lens
If these are not available, ask for them or recommend using delegation-coach first.
Scope boundary
This skill is for:
- writing prompts
- auditing prompts
- turning a known task framing into an execution-ready instruction set
This skill is not primarily for:
- deciding whether the task is ready to delegate
- deciding whether the baseline is clean
- classifying the task from scratch
That is delegation-coach territory.
Quick Start
/skill:prompt-crafter # Interactive: discuss what you need
/skill:prompt-crafter --task "implement X" # Generate a prompt for a specific task
/skill:prompt-crafter --audit # Audit an existing prompt for risk factorsProblem This Solves
When you tell an AI coding agent "follow the existing pattern," it copies EVERYTHING — including the wrong things. Decorators with wrong names, abstractions that don't fit, legacy quirks. This skill helps you write prompts that get the right behavior.
The Thirteen Principles
These come from experimental research (see cargo-cult-findings.md in this skill directory).
Experiments 3–13 tested decorator cargo (surface syntax), semantic cargo (architectural patterns),
defense strategies, and their interaction with prompt variants across multiple models.
1. Clean Your Exemplars First
The #1 intervention. Remove decorative patterns from the code the model will read before worrying about prompt wording.
| Risk Level | Exemplar State | Expected Outcome |
| ✅ Safe | Clean, no decorative patterns on public methods | Model copies structure, no decoration |
| ⚠️ Moderate | 1-2 decorative patterns on public methods | Model copies at 1:1 rate — each pattern transfers |
| ❌ Dangerous | 3+ decorative patterns on public methods | Model copies aggressively, inoculation fails |
| 🛡️ Safe | Decorative patterns on PRIVATE methods only | Patterns don't transfer — no shared surface area |
What to clean:
- Decorators on public methods — these transfer 1:1 (proven by density gradient experiments)
- Import statements for utilities the new task doesn't need
- Legacy compatibility code (aliases, deprecated signatures)
- Over-engineered abstractions (retry wrappers, custom exception hierarchies) that aren't relevant to the new task
What is SAFE to leave:
- Decorative patterns on private methods (
_execute_request,_build_prompt) — these don't transfer because the new file doesn't have those methods - Architectural patterns (retry wrappers, custom error hierarchies, control flow) — these resist transfer because they require semantic understanding, not just pattern matching
- Structural patterns (error handling flow, validation split)
- Interface contracts (method signatures, return types)
- Naming conventions
- Docstring style
2. Avoid "Follow the Pattern" When Cargo Is Present
The phrase "follow the same patterns and conventions" is the single most dangerous instruction when exemplars contain cargo. Experiments showed it's the strongest cargo trigger.
Safe alternatives when exemplar is clean:
- "Follow the same patterns and conventions you see" ← fine, nothing bad to copy
- "Be structurally consistent with the existing code" ← same thing
Safe alternatives when exemplar has cargo:
- "Implement the interface defined in
base.py. Referenceollama.pyfor the general API structure, but adapt everything to the new context." - "Follow the structural approach (error handling, validation) but don't copy provider-specific patterns like decorators or metric names."
- "Use the existing provider as a reference for the interface contract only."
3. Inoculation Is Fragile — Don't Rely On It
Telling the model "don't copy X" works in narrow conditions but can make things worse when exemplar density increases.
| Exemplar Density | Inoculation Result |
| 0 patterns | N/A (nothing to inoculate against) |
| 1-2 patterns | Works, but causes overcorrection (drops ALL patterns) |
| 3+ patterns | REVERSES — inoculated prompts produce MORE cargo than uninoculated |
Instead of inoculation, clean the exemplar. If you can't clean it, use targeted reference instructions (Principle 2) rather than negative instructions.
4. Be Specific About What to Reference
Vague references → cargo. Specific references → clean code.
Bad (vague):
"Look at
ollama.pyand do the same thing for Anthropic."
Good (specific):
"Read
musa/ai/base.pyfor the interface you must implement. Readmusa/ai/providers/ollama.pyfor an example of how one provider handles error translation and connection validation. Your Anthropic provider should use theanthropicPython SDK, not raw HTTP requests."
Best (scoped):
"Your task: implement
AnthropicProviderfollowingBaseAIProvider. Reference material:ollama.pyshows the general pattern for error handling. Constraints: use theanthropicSDK, don't copy Ollama-specific patterns."
5. Specify the SDK/Library Explicitly
Models that see raw HTTP in exemplars may copy it even when a proper SDK exists. State the implementation tool upfront.
"Use the
anthropicPython SDK (already installed)"
This prevents the model from copying the raw requests HTTP approach from a different provider.
6. Separate Interface from Implementation
Structure your prompt in layers:
- Interface layer: "Implement these methods with these signatures" (from base class / contract)
- Reference layer: "Here's an existing example for general approach" (exemplar file)
- Constraint layer: "But use X SDK, don't copy Y-specific patterns"
This prevents the model from treating the exemplar as a template to fill in, which is the mechanism behind cargo-culting.
7. Public Methods Are the Cargo Surface Area
Cargo only transfers across shared public methods. The maximum number of decorators that can transfer equals the number of public methods that exist in both the exemplar and the target file.
Implication: You don't need to scrub private helpers clean. A decorator on
_execute_request() won't transfer because the new file doesn't have _execute_request().
Focus your cleanup on the public interface — call(), call_stream(), check_connection().
Corollary: More shared public methods = higher cargo capacity. A base class with 10 abstract methods can carry more cargo than one with 3.
8. Decorators Are the Gateway Drug — Architectural Patterns Resist Transfer
Surface syntax (decorators, annotations) transfers at near-100% rates. Architectural patterns (retry wrappers, control flow, custom error hierarchies) transfer at ~0–33%.
| Cargo Type | Transfer Rate | Mechanism |
| Decorators / Annotations | ~100% | Pattern matching — easy to copy without understanding |
| Class constants + comments | ~33% ("ghost cargo") | Shape transfers, substance doesn't |
| Architectural patterns (retry, backoff) | ~0% | Requires semantic reasoning about why |
Implication: If your codebase conventions live in decorators, they are maximally cargo-prone. If they live in control flow and architectural patterns, they are naturally resistant. When designing APIs for AI agents to implement, prefer architectural conventions ("wrap calls in a validation step") over decorative ones ("add @validated to each method").
Watch for ghost cargo: The model may copy surface markers of an architectural pattern
(class constants like MAX_RETRIES = 3) without copying the actual implementation. These
unused constants are a weaker form of cargo — present but harmless. They signal the model
saw the pattern but chose not to implement it.
9. Models Can Articulate Why They Reject Patterns
When the pattern is semantically rich (retry logic, not a decorator), models sometimes produce conscious rejections — explicit comments explaining why the pattern wasn't copied:
# Anthropic API doesn't need retry logic in the same way Ollama does
# because their SDK has built-in retry logic for transient errorsThis is a positive signal. It means the model evaluated the pattern's relevance and made a deliberate choice. When you see these comments in AI-generated code, it's evidence of reasoning, not cargo.
Implication: If your prompt asks the model to "follow patterns" and the output has no commentary about pattern choices, the model may be copying reflexively. If it has explicit reasoning about what to adopt and what to skip, that's healthier.
10. Scaffolding Is the Strongest Defense
When you can't clean the exemplar, provide a pre-built skeleton for the target file. Experiment 13 showed scaffolding is the only defense that produced zero cargo across both models — no decorators, no Ollama-specific error handling, nothing.
The skeleton should have:
- Correct class structure and imports
- Method signatures matching the interface contract
- Docstrings explaining purpose
raise NotImplementedErrorin method bodies (or similar placeholder)- No decorative patterns — this is what makes it effective
The model simply fills in the method bodies. By removing the pattern-matching temptation entirely, scaffolding eliminates the mechanism that causes cargo-culting.
Example scaffold:
class AnthropicProvider(BaseAIProvider):
def __init__(self, model: str, api_key: str):
self.provider = "anthropic"
self.model = model
self._client = anthropic.Anthropic(api_key=api_key)
def check_connection(self) -> bool:
# TODO: Implement connection check
raise NotImplementedError
# ... etc11. Self-Review Is an Effective Safety Net
A two-step generate-then-review process catches cargo that slipped through generation. Experiment 13 showed the review step successfully removed all 3 decorators that GLM-5.1 had generated in step 1.
The review prompt should be explicit:
"Review this file for patterns copied from [EXEMPLAR] that don't belong. Check for: decorators, error handling patterns, constants, or imports that are specific to [EXEMPLAR_PROVIDER]. Remove anything that doesn't belong."
Caveat: Self-review only helps if the model generated cargo in the first place. If the model was already clean, the review is redundant. Use it as a safety net, not a primary defense.
12. Code-Level Defenses Are Model-Dependent
Anti-pattern comments in code (e.g., # ⚠️ DO NOT COPY THIS) are not reliable across
models. In Experiment 13:
- GLM-4.7 respected the anti-pattern comments → 0 decorators (full defense)
- GLM-5.1 ignored the anti-pattern comments → 3 decorators (same as baseline)
This means code-level warnings cannot be a recommended defense strategy — what works for one model may completely fail for another. Prefer structural defenses (scaffolding) or process defenses (self-review) that work regardless of model behavior.
13. Model Choice Is Your Strongest Lever — But Not the Only One
Early cargo experiments showed a very large gap between model families. That remains true: stronger models still reduce many forms of shallow cargo and often produce cleaner outputs.
But later Musa experiments (especially the medium-task provider experiments) refine this claim. On architecture-sensitive work, all tested model families still responded to exemplar steering:
- neutral runs drifted toward SDK-oriented / Anthropic-like providers
- Ollama-anchored runs drifted toward raw HTTP providers
- this happened across GPT and GLM models
So the updated rule is:
- model choice affects execution quality, test thoroughness, and reasoning clarity
- exemplar choice often determines the architecture direction
| Factor | What it mainly changes |
| Model choice | quality of execution, boundedness, cleanup burden |
| Exemplar choice | direction of architecture, transport strategy, exception shape |
| Scaffolding | scope discipline and integration spread |
| Review | semantic trust and proof of behavior |
Implication: Before investing time in prompt engineering, first decide:
- is the baseline clean?
- what exemplar am I foregrounding?
- what model am I using?
A strong model helps a lot, but it does not make exemplars neutral.
Defense Hierarchy
Ranked from weakest to strongest, incorporating both the early cargo experiments and the later Musa medium-task experiments:
| Rank | Defense | Effort | Main benefit | Model-Dependent? |
| 0 | None | None | No protection | — |
| 1 | Inoculation ("don't copy X") | Low | Sometimes blocks surface cargo | Yes |
| 2 | Anti-pattern comments in code | Low | Unreliable warning signal | Highly |
| 3 | Better model | Low | Improves execution quality and reduces shallow cargo | — |
| 4 | Specific exemplar scoping | Low-Med | Reduces accidental architecture steering | No |
| 5 | Self-review / adversarial review | Medium | Improves semantic trust and catches missing proof | No |
| 6 | Scaffolding (pre-built skeleton) | Medium | Tightens scope and reduces integration spread | No |
| 7 | Clean baseline + intentional exemplar choice | Medium | Prevents contamination and controls architecture direction | No |
The meta-pattern: better models help, but on medium architecture-sensitive tasks the strongest controls are baseline cleanliness, intentional exemplar choice, scaffolding, and separate review.
Prompt Templates
Template: From delegation-coach handoff brief
Use this task framing to write the final coding prompt:
Task class: [TASK_CLASS]
Workflow: [WORKFLOW]
Exemplar guidance: [EXEMPLAR_GUIDANCE]
Constraints: [CONSTRAINTS]
Validation: [VALIDATION]
Review lens: [REVIEW_LENS]
Write the final prompt for the coding agent using a clear layered structure.Template: New Provider / Module Alongside Existing
You are implementing a new [TYPE] for the [PROJECT] project.
The project has an existing [TYPE] at [EXEMPLAR_PATH] and a base interface at [BASE_PATH].
Your task: Implement a new [NAME] at [TARGET_PATH] and its tests at [TEST_PATH].
Requirements:
- Follow the interface from [BASE_PATH]
- Use the [SDK_NAME] SDK (already installed)
- Implement: [METHOD_LIST]
- Handle errors properly with [ERROR_TYPES]
- Write comprehensive unit tests mocking the [SDK_NAME]
[IF EXEMPLAR IS CLEAN:]
Study [EXEMPLAR_PATH] for the general approach and follow its conventions.
[IF EXEMPLAR HAS CARGO:]
Read [BASE_PATH] for the interface contract. Reference [EXEMPLAR_PATH] for the general
structure of error handling, but adapt everything to the new context. Do NOT copy
[PROVIDER]-specific patterns.
After implementation, run: [TEST_COMMAND]Template: Feature in Existing Module
Add [FEATURE] to [MODULE_PATH].
First, read [MODULE_PATH] to understand the current structure and [RELATED_FILE] for context.
Requirements:
- [REQUIREMENT_1]
- [REQUIREMENT_2]
- Follow the existing code style in the module
- Add tests at [TEST_PATH]
Focus on: [SPECIFIC_BEHAVIOR]
Do NOT: [NEGATIVE_CONSTRAINT — use sparingly, only when exemplar has cargo]
After implementation, run: [TEST_COMMAND]Template: Bug Fix
Fix the bug where [SYMPTOM] occurs when [CONDITION].
Reproduction: [STEPS]
First, read [FILE_PATH] and understand the current logic. The expected behavior is:
[EXPECTED_BEHAVIOR]
Fix the issue with minimal changes. Don't refactor surrounding code unless it's directly
related to the bug.
Add or update a test that would have caught this bug.
After implementation, run: [TEST_COMMAND]Prompt Audit Checklist
When reviewing a prompt before sending it to an AI coding agent:
| Check | Question | Action |
| ☐ Model profile | Is your model stronger or weaker on cargo-prone work? | Stronger = cleaner execution; weaker = more literal copying risk, but exemplars still matter for all models (Principle 13) |
| ☐ Exemplar state | Does the exemplar file contain decorative patterns? | Clean it first (Principle 1) |
| ☐ Public vs private | Are decorative patterns on public or private methods? | Private is safe; public must be cleaned (Principle 7) |
| ☐ Reference specificity | Is "follow the pattern" used near cargo? | Replace with specific reference (Principle 4) |
| ☐ SDK specified | Is the implementation tool/library stated? | Add it explicitly (Principle 5) |
| ☐ Scope bounded | Is it clear what's interface vs implementation? | Use layered structure (Principle 6) |
| ☐ Inoculation used | Are there "don't do X" instructions? | Consider removing — fragile (Principle 3) |
| ☐ Test command | Is the exact test command specified? | Add it to prevent guesswork |
| ☐ Baseline clean | Is the repo/environment/branch state clean enough for the task? | Freeze baseline first — a good prompt cannot rescue contamination |
| ☐ Exemplar steering | Are you intentionally choosing the exemplar for the architecture you want? | Treat examples as steering inputs, not neutral context |
| ☐ Scaffold possible | Can you provide a pre-built skeleton? | Strongest defense for scope control — use it (Principle 10) |
| ☐ Review step planned | Is there a generate-then-review cycle? | Add self-review or adversarial review as safety net (Principle 11) |
| ☐ Code-level warnings | Are you relying on # DO NOT COPY comments? | Unreliable — use structural defenses (Principle 12) |
Anti-Patterns
| Anti-Pattern | Why It's Dangerous | What To Do Instead |
| "Follow the same pattern" | Strongest cargo trigger when exemplar has decorative patterns | Be specific about WHAT to follow |
| Inoculation at high density | Can reverse and increase cargo | Clean the exemplar instead |
| Vague file references | Model treats entire file as template | Scope the reference to specific patterns |
| No SDK specification | Model copies HTTP approach from different provider | State the tool explicitly |
| "Do it however you want" | Missed opportunity to guide toward good patterns | Specify interface + constraints, leave implementation free |
| Long negative lists | "Don't do X, don't do Y, don't do Z" dilutes signal | Fix the exemplar so negatives aren't needed |
| Scrubbing private helpers | Wasted effort — private method patterns don't transfer | Focus cleanup on public methods only |
| Scrubbing architectural patterns | Wasted effort — retry wrappers and control flow resist transfer naturally | Focus cleanup on decorators and annotations instead |
| Ignoring ghost cargo | Unused constants/comments from exemplar signal incomplete reasoning | Review for dead code that references other providers |
| Relying on anti-pattern comments | Model-dependent — one model respects them, another ignores them | Use scaffolding or self-review instead |
| Trusting inoculation for semantic cargo | Inoculation blocks surface patterns but deeper patterns leak through | Use scaffolding for full protection |
| Assuming all models copy equally | Models differ in output quality and cargo behavior | Check both model profile and exemplar risk |
| Assuming a strong model makes exemplars safe | Later Musa experiments show exemplar steering still changes architecture across GPT and GLM | Choose exemplars intentionally even on strong models |
| Prompt-engineering around a bad baseline | Baseline contamination invalidates conclusions no matter how good the prompt is | Freeze repo/environment/branch state first |
| Prompt-engineering around a bad model | Better models help, but framing still determines direction | Improve model choice and exemplar choice together |
When to Use This Skill
- Before delegating to a subagent — craft the prompt using these templates
- Before sending a task to an AI coding tool — audit for cargo risk
- When code reviews show copy-paste patterns — the prompt likely caused it
- When onboarding a new AI tool — set up clean exemplars first
- When refactoring — clean exemplars before asking AI to create new modules
- When designing APIs for AI agents — prefer architectural conventions over decorators
- When reviewing AI-generated code — check for ghost cargo (unused constants from exemplar)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

