| name | agent-environment-optimizer |
| description | Audit an agent's execution environment for cold-start patterns, missing warm caches, stale dependencies, and session persistence gaps. Scores against best practices from OpenAI Hosted Shell and METR research showing unoptimized environments negate AI productivity gains. Use when the user says "optimize agent environment", "cold start audit", "agent environment check", "why is my agent slow to start", "warm cache audit", "session persistence check", or wants to speed up agent execution by fixing the environment layer. |
Agent Environment Optimizer
Audit whether an agent's execution environment follows persistent-environment best practices. Flags cold-start patterns that silently eat productivity gains and suggests fixes.
Source
Nate's Newsletter, 2026-04-16. References OpenAI's Hosted Shell pattern and METR study showing unmodified environments negate AI gains.
Trigger
Use when the user asks about agent startup speed, execution environment optimization, cold-start problems, or why their agent takes so long before doing useful work.
Prerequisites
- Target environment must be accessible (local machine, SSH target, or container)
- Works for Claude Code, the agent platform agents, or any LLM agent setup
Phase 1: Environment Discovery
Identify the agent's execution context:
- Runtime type: local process, container, SSH remote, cloud VM
- Session model: ephemeral (fresh each run) vs. persistent (long-lived process)
- Entry point: how the agent starts (CLI, daemon, cron, webhook)
Gather data:
python3 --version 2>/dev/null; node --version 2>/dev/null
ls -la ~/.cache/pip/ 2>/dev/null; ls -la ~/.npm/_cacache/ 2>/dev/null
ls -la ~/.cache/pre-commit/ 2>/dev/null
git status 2>/dev/null | head -5
Phase 2: 6-Dimension Assessment
Score each dimension 1-5 (1 = fully cold, 5 = fully warm):
D1: Dependency Availability
D2: Compilation Cache
D3: Context Pre-loading
D4: Auth Persistence
D5: Session Continuity
D6: Tool Readiness
Phase 3: Cold-Start Pattern Detection
Flag these specific anti-patterns:
| Pattern | Signal | Impact |
|---|
| Install-on-boot | pip install / npm install in entrypoint | 30-120s added per start |
| Auth-on-first-call | Token fetch in first tool invocation | 2-10s + potential failure |
| Index-on-demand | File indexing triggered by first search | 5-60s depending on repo size |
| Cache-miss cascade | No pycache, no .next/, no node_modules/.cache | Cumulative 10-30s |
| Context-reload | Full CLAUDE.md chain re-parsed every message | Token waste per turn |
| Ephemeral workspace | /tmp or container with no volume mount | All state lost between runs |
Phase 4: Optimization Report
Produce a scorecard:
Agent Environment Score: XX/30
D1 Dependency Availability: X/5
D2 Compilation Cache: X/5
D3 Context Pre-loading: X/5
D4 Auth Persistence: X/5
D5 Session Continuity: X/5
D6 Tool Readiness: X/5
Cold-Start Patterns Found: N
Estimated startup overhead: ~Xs
Then list fixes ranked by impact:
#1 FIX: [Pattern name]
Current: [what happens now]
Target: [what should happen]
How: [specific command or config change]
Saves: ~Xs per agent start
Phase 5: Implementation Checklist
Generate a concrete checklist the user can execute:
Verification
- All 6 dimensions assessed with evidence (not assumed)
- Cold-start patterns backed by actual file/config checks, not guesses
- Fix recommendations are specific enough to execute without further research
- Estimated time savings are conservative (under-promise)