AI Coding Tip 005 - Keep Context Fresh
Keep your prompts clean and focused, and stop the context rot

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
Search for a command to run...
Keep your prompts clean and focused, and stop the context rot

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
No comments yet. Be the first to comment.
Approve the logic once, then let it run the same way forever.

Different stages need different brains.

One Second Brain doesn't scale past one skull.

Style errors double when nobody enforces them.

Know who speaks before the skill runs TL;DR: Always define a clear role at the top of every skill file so you know whose perspective drives the execution. Common Mistake ❌ You write a skill full of

TL;DR: Clear your chat history to keep your AI assistant sharp.
You keep a single chat window open for hours.
You switch from debugging a React component to writing a SQL query in the same thread.
The conversation flows, and the answers seems accurate enough.
But then something goes wrong.
The AI tries to use your old JavaScript context to help with your database schema.
This creates "context pollution."
The assistant gets confused by irrelevant data from previous tasks and starts to hallucinate.
Large Language Models use an "Attention" mechanism.
When you give them a massive history, they must decide which parts matter.
Just like a "God Object" in clean code, a "God Chat" violates the Single Responsibility Principle.
When you keep it fresh and hygienic, you ensure the AI's "working memory" stays pure.
Bad Prompt (Continuing an old thread):
Help me adjust the Kessler Syndrome Simulator
in Python function to sort data.
Also, can you review this JavaScript code?
And I need some SQL queries tracking crashing satellites, too.
Use camelCase.
Actually, use snake_case instead. Make it functional.
No, wait, use classes.
Change the CSS style to support
dark themes for the orbital pictures.
Sort the data from @kessler.py#L23.
Update the tests using the skill run-tests.
You must extract agents.md or skills.md before starting the new chat. (Like you would when coaching a new team member)
Use metacognition: Write down what you have learned. (Like you would when coaching a new team member)
The AI will not remember them across threads. (Like you would when coaching a new team member)
[X] Semi-Automatic
[X] Intermediate
Place the most important instructions at the beginning or end
Fresh context leads to incrementalism and small solutions, Failing Fast.
When you start over, you win back the AI's full attention and fresh tokens.
Pro-Tip 1: This is not just a coding tip. If you use Agents or Assistants for any task, you should use this advice.
Pro-Tip 2: Humans need to sleep to consolidate what we have learned in the day; bots need to write down skills to start fresh a new day.
Full Prompt Engineering Guide: Context Management
Anthropic Context Window Best Practices
Token Economy in Large Language Models
Context Reset
Thread Pruning
Session Hygiene
The views expressed here are my own.
I am a human who writes as best as possible for other humans.
I use AI proofreading tools to improve some texts.
I welcome constructive criticism and dialogue.
I shape these insights through 30 years in the software industry, 25 years of teaching, and writing over 500 articles and a book.
This article is part of the AI Coding Tip series.