Agentic Engineering Best Practices
A guide to getting maximum output from coding agents like Claude Code and Codex, based on extensive production experience. The core message: strip away complexity, control context, and iterate on rules and skills over time.
Source: SysLS (@systematicls)
Foundational Principles
The World Is Sprinting By
Foundation companies are on a generational run. Every new generation of models changes optimal workflows. If a problem is real and common, frontier companies will incorporate the solution into their base product (skills, memory, subagents, and planning all started as external tools before becoming core features).
Implication: Don't lock into external libraries and harnesses. They solve problems that may not exist in the next model generation. Keep your setup barebones: just the CLI and your CLAUDE.md.
Context Is Everything
The single most important factor in agent performance. Agents perform best when given the exact information needed for the current task and nothing more. Context bloat from plugins, memory systems, and accumulated session history degrades performance.
"You want to give your agents only the exact amount of information they need to do their tasks and nothing more!"
Separate Research from Implementation
When not precise, agents waste context researching alternatives. "Go and build an auth system" forces research on all auth options. "Implement JWT authentication with bcrypt-12 password hashing, refresh token rotation with 7-day expiry" gives clean implementation context.
If you don't have implementation details: create a research task first, make the decision, then implement in a fresh session.
Managing Sycophancy
Agents want to please. If you say "find me a bug," it will find one, even if it has to engineer one. This is a design property, not a flaw.
Mitigations:
- Neutral prompts: Instead of "find me a bug in the database," say "search through the database, follow along with the logic, and report back all findings"
- Exploit it constructively: Use the bug-finder / adversarial / referee pattern (see building-ai-agents)
- Scoring systems: "+1 for low-impact bugs, +5 for medium, +10 for critical" then use an adversarial agent to challenge the findings
Compaction, Context, and Assumptions
Agents are still poor at "connecting the dots" and making assumptions. After compaction (context compression), they lose track of what they were doing.
Solution: Add a rule in CLAUDE.md that after every compaction, the agent should:
- Re-read the task plan
- Re-read relevant files
- Only then continue working
How to Use CLAUDE.md
Treat CLAUDE.md as a logical, nested directory of where to find context given a scenario. It should be barebones: only IF-ELSE logic pointing to where context lives.
If coding → read coding-rules.md
If writing tests → read coding-test-rules.md
If tests failing → read coding-test-failing-rules.md
Rules
Encode preferences: things you don't want the agent to do. If you see unwanted behavior, add a rule and tell the agent to read it before doing that thing again.
Skills
Encode recipes: specific ways you want something done. If you want deterministic problem-solving, have the agent research the approach and write it as a skill. You can review and correct the approach before it's used in practice.
Maintenance
Over time, rules and skills accumulate and start contradicting each other, causing context bloat. Periodically: tell the agent to consolidate rules and skills, remove contradictions, and ask you for updated preferences.
Letting Agents Know How to End Tasks
Agents know how to start but not how to end. Without clear completion criteria, they implement stubs and call it done.
Effective endpoints:
- Tests: Deterministic and clear. "Unless these X tests pass, your task is NOT complete; you are NOT allowed to edit the tests."
- Screenshots + verification: Have the agent implement, take a screenshot, verify against design, iterate.
- Task contracts:
{TASK}_CONTRACT.mdspecifying all tests, screenshots, and verification required before termination.
Long-Running Agents
24-hour sessions are not optimal because they accumulate irrelevant context from unrelated tasks.
Better approach: One new session per task contract. An orchestration layer creates contracts when work needs doing and spawns fresh sessions for each.
Stop-hooks can prevent termination until all contract conditions are met, but keep sessions scoped to single contracts.
The Meta-Principle: Iterate
Start barebones. Use the basic CLI. Add preferences as rules. Add recipes as skills. When performance degrades, consolidate and clean up. Repeat.
"That's it. That's really the secret. Keep it simple, use rules and skills and CLAUDE.md as a directory and be religiously mindful about their context and their design limitations."
Related Topics
- context-engineering - The theory behind why context management matters
- building-ai-agents - Practical agent construction patterns
- scaling-autonomous-coding - How these principles apply at multi-agent scale
- auto-research - Agents that optimize their own harnesses
- agent-memory-and-harnesses - Why open harnesses matter for owning your agent's memory