{"slug": "harness-engineering-stop-re-prompting-your-coding-agent-every-session", "title": "Harness Engineering: Stop Re-Prompting Your Coding Agent Every Session", "summary": "A developer has created a \"harness engineering\" approach to eliminate the need for re-prompting coding agents in every new session. Instead of relying on session-scoped prompts that disappear, the method stores durable artifacts like `AGENTS.md` instruction files, architecture constraints, and knowledge stores directly in the repository. The developer built a starter kit that applies this pattern to any existing project, allowing agents to automatically read project rules at the start of each session without requiring repeated explanations.", "body_md": "Every time I started a new agent session, I was re-explaining the same things.\n\nThe architecture rules. The patterns to avoid. The decisions I'd already made. The approaches that already failed.\n\nThe agent would forget everything and I'd be back to square one.\n\nMy first instinct was to write better prompts. Longer, more detailed, more explicit. But that just made the problem worse — now I had a 200-line prompt to maintain, and the agent still forgot it all next session.\n\nThe real problem isn't the prompt. **Prompts are session-scoped. They disappear.**\n\nInstead of putting rules in prompts, what if we put them in the repository itself?\n\nPrompting is temporary. Context is session-scoped. A harness is project-scoped.\n\nThe idea is simple: every time an agent makes a recurring mistake, convert it into a durable artifact in the repo instead of re-prompting.\n\n`docs/decisions/`\n\n`docs/failures/`\n\n`AGENTS.md`\n\nThe repository gets smarter with every mistake. The agent reads the repo at the start of each session and picks up all the rules automatically — no prompting required.\n\n**1. AGENTS.md — Instruction Document**\n\nA file the agent reads at the start of every session. Contains project overview, directory rules, forbidden patterns, test commands, and PR behavior. Think of it as a permanent briefing document.\n\n**2. Architecture Constraints**\n\nAutomated rules that block invalid code before it merges. Linters, type checks, import boundaries, pre-commit hooks. If `AGENTS.md`\n\nsays \"no direct DB access from routes\", add a lint rule that enforces it.\n\n**3. Feedback Loops**\n\nSignals the agent uses to self-correct. Test failures, CI failures, lint errors. A good harness gives the agent clear, actionable failure messages so it can fix its own mistakes.\n\n**4. Knowledge Store ( docs/)**\n\nDurable context that survives session resets:\n\n`docs/decisions/`\n\n— why certain architectural choices were made`docs/failures/`\n\n— approaches already tried and rejected`docs/conventions/`\n\n— project-specific coding rules`docs/domain/`\n\n— business terminology and domain knowledge**5. Drift Checks**\n\nScripts that detect when the harness itself goes stale. Is `AGENTS.md`\n\nreferencing files that no longer exist? Are there temporary files that never got cleaned up? Drift checks catch this automatically.\n\nI built a starter kit that applies this pattern to any existing project.\n\n**Usage:**\n\nClone it inside your target repo:\n\n```\nworkspace/\n└── target-repo/\n    ├── harness-starter-kit/\n    └── existing project files\n```\n\nThen give your coding agent this prompt:\n\n```\nRead ./harness-starter-kit first, then apply the harness engineering \nstarter kit to this repository. Preserve existing architecture, tools, \nand conventions. Do not overwrite existing files without explaining why.\nFinish with a short adoption report.\n```\n\nThe agent inspects your repo, adapts to your existing tools (eslint, tsc, ruff, etc.), and installs only the missing harness files.\n\n**Key design decisions:**\n\nBetter prompting is a local fix. Harness engineering is a systemic fix.\n\nEvery recurring agent failure should become at least one durable artifact — a clearer rule, an automated constraint, a test, a decision record, or a drift check. That's the core loop.\n\nThe goal isn't to write the perfect prompt. It's to build a repository that makes the same mistakes increasingly unlikely over time.\n\nHave you been dealing with agents repeating the same mistakes? How are you handling it?", "url": "https://wpnews.pro/news/harness-engineering-stop-re-prompting-your-coding-agent-every-session", "canonical_source": "https://dev.to/baskduf/harness-engineering-stop-re-prompting-your-coding-agent-every-session-4lec", "published_at": "2026-05-26 05:10:05+00:00", "updated_at": "2026-05-26 05:33:37.313657+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-products", "large-language-models", "artificial-intelligence"], "entities": [], "alternates": {"html": "https://wpnews.pro/news/harness-engineering-stop-re-prompting-your-coding-agent-every-session", "markdown": "https://wpnews.pro/news/harness-engineering-stop-re-prompting-your-coding-agent-every-session.md", "text": "https://wpnews.pro/news/harness-engineering-stop-re-prompting-your-coding-agent-every-session.txt", "jsonld": "https://wpnews.pro/news/harness-engineering-stop-re-prompting-your-coding-agent-every-session.jsonld"}}