{"slug": "10-rules-for-getting-better-results-from-ai-coding-agents", "title": "10 Rules for Getting Better Results from AI Coding Agents", "summary": "HackerRank's 2025 Developer Skills Report found that 97% of developers use at least one AI assistant and nearly a third of code is now AI-generated, prompting a set of 10 practical rules for improving results from AI coding agents such as Claude Code, Codex, Cursor, Copilot Agent, and Gemini CLI. The rules emphasize starting with detailed specifications, using repository-level instruction files like AGENTS.md, and keeping instructions concise to avoid context overload.", "body_md": "# 10 Rules for Getting Better Results from AI Coding Agents\n\nEveryone's using AI coding agents. Here's how to make yours actually useful.\n\nAI coding agents are no longer just autocomplete tools. They can read your repository, edit multiple files, run commands, create pull requests, and work through multi-step development tasks. ** Claude Code**,\n\n**,**\n\n[Codex](https://openai.com/index/introducing-codex/)**,**\n\n[Cursor](https://cursor.com/)**,**\n\n[Copilot Agent](https://github.com/features/copilot/agents)**, and similar tools are changing how developers build software. But better tools do not automatically mean better code.**\n\n[Gemini CLI](https://geminicli.com/)** HackerRank's 2025 Developer Skills Report** found that 97% of developers use at least one AI assistant, and that nearly a third of code is now AI-generated. It also notes that AI is increasing delivery pressure, not removing the need for strong engineering judgment.\n\nThe difference between a good AI-assisted developer and a frustrated one often comes down to workflow. AI coding agents perform best when they are given clear goals, project context, validation rules, and a safe way to iterate. Here are **10 practical rules for getting better results**.\n\n## # 1. Starting With a Specification, Not a Vague Prompt\n\n**Bad prompt:**\n\n```\nBuild the dashboard.\n```\n\n**Better prompt:**\n\n```\nBuild a customer churn dashboard.\n\nGoal:\nShow churn rate, active customers, monthly revenue, and top churn risk factors.\n\nScope:\n- Add a dashboard page at /dashboard.\n- Use the existing API client.\n- Reuse the current chart component.\n- Do not change the database schema.\n\nAcceptance criteria:\n- Page loads without console errors.\n- Metrics match the /analytics/churn endpoint.\n- Add tests for the data transformation function.\n- Run lint and tests before final response.\n```\n\nCoding agents are good at execution, but they need a target. A good specification should include the goal, scope, constraints, files likely to change, acceptance criteria, and test commands. This mirrors how professional developers already work: the task is not \"write code,\" but \"make a change that satisfies a clear definition of done.\"\n\nA recent paper on ** coding-agent bootstrapping** makes a similar point from a research angle: for agents, the specification can become the stable artifact of record, while implementations may be regenerated or revised.\n\n## # 2. Using an `AGENTS.md`\n\n, `CLAUDE.md`\n\n, or Copilot Instructions File\n\nDo not repeat the same project rules in every prompt. Put persistent instructions in a repository-level agent file.\n\nThe open `AGENTS.md`\n\nformat describes itself as a README for agents: a predictable place to give coding agents setup commands, test commands, coding conventions, and repository-specific instructions. It is already used by more than 60,000 open-source projects.\n\nFor example:\n\n```\n# AGENTS.md\n\n## Setup\n- Install dependencies with `pnpm install`.\n- Start the app with `pnpm dev`.\n- Run tests with `pnpm test`.\n\n## Code style\n- Use TypeScript strict mode.\n- Prefer functional components.\n- Do not add new dependencies without approval.\n\n## Before finishing\n- Run lint.\n- Run relevant tests.\n- Summarize changed files and why they changed.\n```\n\nCodex reads `AGENTS.md`\n\nbefore doing work and supports layered guidance from global, project, and directory-specific files. ** GitHub Copilot** also supports repository custom instructions in\n\n`.github/copilot-instructions.md`\n\n, which can tell the agent how to build, test, validate, and follow project conventions.\n\n## # 3. Keeping Agent Instructions Short and Useful\n\nAn agent instruction file is not the place to paste your entire engineering handbook.\n\n** Anthropic's skill-authoring guidance** says good skills should be concise, well-structured, and tested with real usage. It also warns that once instructions are loaded, every token competes with the rest of the task context.\n\nA recent paper on found common \"configuration smells,\" including lint leakage, context bloat, skill leakage, and conflicting instructions. In its sample of 100 popular repositories, lint leakage appeared in 62% of files and context bloat in 42%.\n\n`AGENTS.md`\n\nand `CLAUDE.md`\n\nfilesGood instruction files include:\n\n- How to install, build, test, and lint.\n- Project-specific architecture notes.\n- Naming and style rules.\n- Security constraints.\n- What not to touch.\n- How to report completion.\n\nBad instruction files include:\n\n- Generic coding advice the model already knows.\n- Long explanations of common frameworks.\n- Contradictory rules.\n- Outdated commands.\n- Too many \"always\" and \"never\" instructions.\n\n## # 4. Asking the Agent to Inspect Before Editing\n\nFor non-trivial tasks, tell the agent to understand the repository before changing it.\n\nExample:\n\n```\nBefore editing, inspect the relevant files and summarize:\n1. which files control authentication,\n2. where the bug likely lives,\n3. what tests already cover this area,\n4. the smallest safe change.\nDo not modify files until after this summary.\n```\n\nThis prevents the common failure mode where the agent writes a plausible fix in the wrong location. Make the agent locate the system before asking it to change the system.\n\n## # 5. Using Planning for Complex Tasks, but Not Over-Planning Tiny Edits\n\nFor large changes, a plan helps. For small changes, too much planning slows the loop.\n\n** GitHub Copilot CLI's best-practices documentation** explicitly recommends plan mode for tasks where a structured implementation plan is useful before code is written.\n\nUse planning for:\n\n- Migrations.\n- Multi-file refactors.\n- Auth changes.\n- Database changes.\n- Performance work.\n- Production bug fixes.\n- Anything touching security or payments.\n\nSkip heavy planning for:\n\n- Typo fixes.\n- Small test additions.\n- Simple CSS changes.\n- One-function refactors.\n\n## # 6. Making Tests the Contract\n\nAI-generated code often looks right before it is right.\n\n** HackerRank** argues that debugging is becoming a central AI-age skill because AI-generated code still needs reliability, security, and integration work. Its guidance recommends practical, multi-file debugging scenarios with failing tests, misleading logs, and integration edge cases.\n\nUse tests as the agent's contract:\n\n```\nWrite failing tests first for this bug.\nConfirm they fail.\nThen implement the smallest fix.\nDo not modify the tests after implementation unless the test itself is wrong.\nRun the relevant test suite before finishing.\n```\n\nThis pattern is especially powerful with agents because it gives them a feedback loop. Without tests, the agent optimizes for plausible code. With tests, it optimizes for working code.\n\n## # 7. Giving Examples of the Desired Style\n\nAgents follow examples better than abstract taste.\n\nInstead of saying:\n\n```\nMake it clean and production-ready.\n```\n\nSay:\n\n```\nFollow the style of `src/features/billing/CreateInvoice.tsx`.\nUse the same error-handling pattern as `src/lib/apiClient.ts`.\nUse the existing `Result<T>` type instead of throwing raw errors.\n```\n\n** GitHub's Copilot best-practices guide** recommends breaking down complex tasks, being specific, providing examples of inputs and outputs, and following good coding practices when prompting. Examples reduce ambiguity. They also prevent the agent from inventing a new style that conflicts with the existing codebase.\n\n## # 8. Controlling Dependencies and Permissions\n\nAgents like to solve problems by installing packages, changing configs, or widening permissions. That may work locally but create long-term maintenance risk.\n\nAdd rules such as:\n\n```\n## Dependency policy\n- Do not add production dependencies without approval.\n- Prefer existing utilities before adding new packages.\n- If a new dependency is necessary, explain why and list alternatives.\n```\n\nThis is especially important because modern coding agents can run commands and interact with development tools. If your tool supports hooks or permission controls, use them. ** Claude Code hooks** can run deterministic commands at specific lifecycle points, which is useful when you need certain checks to happen reliably rather than hoping the model remembers.\n\n## # 9. Reviewing AI Changes\n\nDo not review AI-generated code by asking, \"Does it look good?\"\n\nReview it by asking:\n\n- Did it solve the requested problem?\n- Did it change unrelated behavior?\n- Did it add unnecessary abstraction?\n- Did it weaken security?\n- Did it hide errors instead of fixing them?\n- Did it update tests?\n- Did it follow project conventions?\n- Can the diff be smaller?\n\nExperienced developers value agents as productivity tools, but still retain control over design and implementation because they care about quality attributes. This is the right mental model. The agent can draft, explore, refactor, and test. The developer still owns architecture, correctness, and maintainability.\n\n## # 10. Iterating on Your Agent Instructions\n\nYour first `AGENTS.md`\n\nwill not be perfect.\n\nWhen the agent makes a mistake, do not only fix the code. Fix the instruction that allowed the mistake.\n\nExample:\n\nAgent mistake:\n\nIt modified generated files directly.\n\nInstruction update:\n\n```\n## Generated files\n- Do not edit files in `src/generated/`.\n- Update the schema or generator source instead.\n- If unsure, ask before changing generated files.\n```\n\nAgent mistake:\n\nIt ran the entire slow test suite every time.\n\nInstruction update:\n\n```\n## Test strategy\n- For frontend component changes, run the affected component tests first.\n- Run the full test suite only before final completion or when shared utilities change.\n```\n\n## # Final Thoughts\n\nAI coding agents reward developers who can write clear specifications, design good feedback loops, and review code carefully. The goal is not to \"vibe code\" your way through production systems. The goal is to turn the agent into a faster implementation partner inside a controlled engineering workflow.\n\nThe best results come from giving the agent:\n\n- A clear task.\n- A small, accurate context.\n- A repository instruction file.\n- Examples of existing style.\n- Tests as a contract.\n- Permission boundaries.\n- A human reviewer who still owns the outcome.\n\n**In short:** better agent output does not start with a better model. It starts with better engineering discipline.\n\nis a machine learning engineer and a technical writer with a profound passion for data science and the intersection of AI with medicine. She co-authored the ebook \"Maximizing Productivity with ChatGPT\". As a Google Generation Scholar 2022 for APAC, she champions diversity and academic excellence. She's also recognized as a Teradata Diversity in Tech Scholar, Mitacs Globalink Research Scholar, and Harvard WeCode Scholar. Kanwal is an ardent advocate for change, having founded FEMCodes to empower women in STEM fields.\n\n**Kanwal Mehreen**", "url": "https://wpnews.pro/news/10-rules-for-getting-better-results-from-ai-coding-agents", "canonical_source": "https://www.kdnuggets.com/10-rules-for-getting-better-results-from-ai-coding-agents", "published_at": "2026-08-26 12:00:50+00:00", "updated_at": "2026-08-26 12:46:03.958207+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "artificial-intelligence"], "entities": ["HackerRank", "Claude Code", "Codex", "Cursor", "Copilot Agent", "Gemini CLI", "GitHub Copilot", "Anthropic"], "alternates": {"html": "https://wpnews.pro/news/10-rules-for-getting-better-results-from-ai-coding-agents", "markdown": "https://wpnews.pro/news/10-rules-for-getting-better-results-from-ai-coding-agents.md", "text": "https://wpnews.pro/news/10-rules-for-getting-better-results-from-ai-coding-agents.txt", "jsonld": "https://wpnews.pro/news/10-rules-for-getting-better-results-from-ai-coding-agents.jsonld"}}