Coding agents waste 15 minutes rebuilding environments that are already running
Our coding agent was rebuilding the same Docker environment every session, burning 15 minutes and $8 in API costs just to get back to where it left off yesterday.
The problem wasn't the agent's memory — it was treating every conversation like a fresh start. Your coding agent needs to know what's already running before it starts rebuilding everything from scratch.
Here's the environment awareness pattern that fixed it:
# Add to your coding agent's system prompt ## Environment Check Protocol Before starting any development work: 1. Run `docker ps` to see what's already running 2. Check `ps aux | grep node` for active processes 3. Look for `.env` files and existing configs 4. Test existing endpoints with curl before rebuilding If services are running and responding correctly, USE THEM. Don't rebuild what works.
But the real fix was giving it a session state file. Every time the agent starts work, it checks ~/.agent_session_state first:
# ~/.agent_session_state LAST_SESSION: 2024-01-15 14:30 PROJECT: /Users/dev/myapp DOCKER_RUNNING: postgres:5432, redis:6379, app:3000 TESTS_PASSING: true BRANCH: feature/auth-fixes NOTES: Auth middleware working, need to add rate limiting
Now when the agent starts a new conversation, it reads this file first and knows exactly what's already set up. No more "let me rebuild your entire development environment" when Docker Compose is already running perfectly.
Pro tip: Make your agent update this file at the end of every session. It's like leaving notes for the next shift.
The session state pattern works for any persistent agent work:
- Research agents: Track which sources you've already checked
- Content agents: Remember which drafts are in progress
- Support agents: Know which tickets are actively being worked
Your agent shouldn't have to rediscover your entire setup every time you start a conversation. Give it the context it needs to pick up where it left off, not start from zero.
We went from 15-minute environment rebuilds to 30-second context checks. The agent is faster, cheaper, and doesn't waste time solving problems that are already solved.