Rewrite a Bloated System Prompt
Take a real system prompt with common anti-patterns and restructure it using the Pyramid and Select patterns. Measure the token difference.
Setup
You’ll need:
- The bloated system prompt file (download above)
- Python 3.8+ with tiktoken (
pip install tiktoken), or use the OpenAI Tokenizer web tool - A text editor
Context
This exercise applies two patterns:
- The Pyramid: structure context so the most important information comes first. Models attend more strongly to the beginning and end of context.
- Select, Don’t Dump: every token has a cost. Choose what earns its place in the context window. Cut what the model won’t use in the next few turns.
Read both pattern pages before starting if you haven’t already.
Your Task
You have a system prompt for a coding assistant. It works, but it’s expensive and underperforms. The prompt has several common problems baked in.
- Count the tokens: Run the prompt through the token counter. Note the number.
- Read it carefully: Identify what’s wrong:
- What’s in the wrong position?
- What’s redundant?
- What doesn’t need to be in the prompt at all?
- Rewrite it: Apply Pyramid structure (critical constraints first, details later) and Select (cut what doesn’t earn its tokens).
- Count again: What’s your token reduction?
- (Optional) Run both versions against a model with the same user message. Compare the output quality.
Scoring
Check your rewrite against this rubric:
- ☐ Moved highest-priority instructions to the top (Pyramid)
- ☐ Removed redundant or repeated instructions
- ☐ Cut pasted documentation that could be tool-retrieved instead (Select)
- ☐ Removed vague filler (“be helpful”, “think carefully” with no specific purpose)
- ☐ Achieved >30% token reduction without losing functional requirements
- ☐ The rewritten prompt still conveys all necessary constraints
Hint: what to cut first
Look for instructions that restate the model’s default behavior. “Be helpful and provide accurate information” costs tokens and changes nothing. Also look for documentation blocks pasted inline that the model could retrieve via a tool call.
Hint: where to put constraints
The most common mistake is putting the role description (“You are a senior software engineer…”) at the very top and burying behavioral constraints (“Never modify files outside the project directory”) at the bottom. Flip that. Constraints and guardrails go first. Identity and style go later.
Solution: expert rewrite
This section will contain an annotated expert rewrite with before/after token counts and reasoning for each change. Waiting on exercise data files (TODO-faafcfff).