Tag: agentic development

  • When AI Writes the Tests: How to Keep Agentic Development Fast Without Letting Flaky Checks Slow You Down

    When AI Writes the Tests: How to Keep Agentic Development Fast Without Letting Flaky Checks Slow You Down

    The New Bottleneck: Trusting the Tests

    Picture a small product team preparing a release. An AI coding agent has implemented a feature, updated a few files, and helpfully generated new tests. The pull request looks impressive: coverage is higher, the suite passes, and the change appears ready before lunch. Then the same tests fail on the next run with no code changes. Or worse, they keep passing while a real bug slips into production.

    That is the tension of agentic development. AI tools can speed up more than application code. They now write tests, update mocks, propose CI configuration, add fixtures, revise release scripts, and summarize changes for reviewers. The question is no longer whether AI can help create tests. It is whether those tests are trustworthy enough to protect the product.

    Flaky Tests and Quality Gates, in Plain Language

    A flaky test is a test that sometimes passes and sometimes fails without a meaningful change in the software being tested. Flakiness can come from timing assumptions, random data, shared state, external network calls, file-system differences, time zones, race conditions, or tests that depend on being run in a particular order.

    A quality gate is a rule in the delivery pipeline that decides whether a change is allowed to move forward. Common quality gates include passing unit tests, minimum coverage thresholds, static analysis checks, security scans, required code review, and deployment approvals. In healthy CI/CD, quality gates are not bureaucracy. They are the automated and human checkpoints that help fast teams avoid preventable problems.

    When AI agents generate tests, the quality gate itself needs scrutiny. A test suite that passes is useful only if it checks the right behavior in a repeatable way.

    Why AI Agents Are Touching More Than Application Code

    Modern coding agents are increasingly used as end-to-end development assistants. A developer may ask an agent to fix a bug, and the agent may respond by editing source code, adding a regression test, updating snapshots, modifying CI commands, and summarizing the change. That is useful because real software work is rarely limited to one file.

    Industry research points toward broader adoption of coding agents across development workflows. Anthropic’s 2026 Agentic Coding Trends Report describes software development as shifting toward orchestrating agents that write code and highlights ongoing tradeoffs around productivity, oversight, quality, and security. Gartner also reported in May 2026 that the enterprise AI coding agent market was entering a phase of expansion and competitive realignment.

    The benefit is obvious: AI can produce first-draft tests faster than most teams can write them by hand. The risk is quieter: agents are often optimized to satisfy the visible request. If the prompt says, “add tests and make CI pass,” an agent may write tests that are technically valid but weak, over-mocked, too tightly coupled to implementation details, or blind to the behavior users actually depend on.

    A Good Test Is More Than a Test That Exists

    A good test protects an important behavior. It should fail when that behavior breaks and pass when the behavior works. That sounds simple, but it is exactly where many AI-generated tests need human review.

    A weak test might verify that a function was called instead of verifying the result users care about. A brittle test might assert the exact wording of an internal error message that was never part of the product contract. An over-mocked test might replace every dependency with fake objects, proving only that the mocks behave as expected. A snapshot test might lock in a large block of output without making clear which part matters.

    Good tests tend to be specific, deterministic, readable, and connected to real risk. They explain the system’s expected behavior in a way another developer can understand six months later. AI can help draft them, but engineering judgment decides whether they are meaningful.

    Common Failure Modes in Agent-Generated Tests

    • Brittle assertions: The test checks incidental details, such as private method calls, object ordering that is not guaranteed, or exact formatting that users never see.
    • Excessive mocking: The test replaces so much of the system that the meaningful integration path is never exercised.
    • False confidence: Coverage increases, but the new tests do not check edge cases, failure handling, permissions, data integrity, or user-visible outcomes.
    • Nondeterministic behavior: The test depends on real time, random values, network availability, file-system state, local configuration, or test execution order.
    • Fixture sprawl: The agent creates large test fixtures that are hard to understand, hard to maintain, and easy to accidentally misuse.
    • Snapshot overload: The test approves a large generated output without explaining which fields are important and which are incidental.
    • Happy-path bias: The test confirms the ideal case but ignores invalid input, empty states, rate limits, authentication boundaries, and recovery from failed dependencies.
    • CI mismatch: The test passes locally but fails in CI because the agent assumed a different runtime, database state, environment variable, locale, or dependency version.

    Recent research into agent-generated tests reinforces the point. A July 2026 arXiv paper analyzing 204,673 test artifacts from the AIDev dataset reported that agent-generated tests showed stronger edge-case variety than human-authored tests in the studied sample, but also a higher candidate rate for flakiness, largely tied to file I/O and nondeterministic logic. In other words, AI-written tests can be useful and still require review for robustness.

    A Lightweight Review Checklist Before Merging

    Teams do not need a heavyweight process for every AI-generated test. They do need a consistent review habit. Before merging a pull request that contains agent-written or agent-modified tests, ask these questions:

    • What behavior is this test protecting? If the answer is not clear, rename or rewrite the test.
    • Would this test fail if the real bug came back? Regression tests should prove the fix, not just execute nearby code.
    • Is the test deterministic? Remove dependence on real time, random data, network calls, shared files, or execution order unless those are deliberately controlled.
    • Are the mocks hiding the risk? Mock external systems where necessary, but keep enough real behavior to validate the integration that matters.
    • Is the assertion about an outcome or an implementation detail? Prefer user-visible results, persisted state, emitted events, API responses, or documented contracts.
    • Is the fixture small and intentional? Test data should be readable and relevant, not a large blob created just to satisfy setup requirements.
    • Does the test cover failure paths? AI often writes happy-path tests first; reviewers should look for permissions, invalid input, empty data, retries, and error handling.
    • Will this test be understandable later? If a future maintainer cannot tell why it exists, it is not finished.

    CI/CD Guardrails That Keep Speed From Becoming Chaos

    Quality gates work best when they make the desired behavior easy and risky behavior visible. For AI-generated tests, the goal is not to slow teams down. The goal is to prevent a fast feedback loop from becoming a noisy feedback loop.

    • Use deterministic fixtures: Keep test data stable, minimal, and isolated. Seed databases predictably and avoid depending on production-like randomness.
    • Isolate test data: Each test should create and clean up its own data or run inside a disposable environment. Shared state is a common source of flakiness.
    • Block real network calls by default: Unit tests and most integration tests should not depend on live third-party services. Use recorded responses, contract tests, or controlled test doubles.
    • Control time and randomness: Freeze clocks, seed random generators, and avoid tests that change behavior based on the current date or local time zone.
    • Set coverage thresholds carefully: Coverage can prevent backsliding, but it should not reward meaningless tests. Use it as one signal, not the only signal.
    • Consider mutation testing where appropriate: Mutation testing can reveal whether tests actually detect changed behavior, though it may be too slow or costly for every pipeline.
    • Require human review for high-risk paths: Authentication, payments, data deletion, privacy-sensitive workflows, migrations, and permission logic deserve explicit human approval.
    • Add flaky-test quarantine policies: If a test is flaky, track it, quarantine it temporarily if needed, assign ownership, and fix or delete it. Do not let random failures become normal.
    • Measure test health over time: Track retry rates, duration changes, failure frequency, and which tests are most often quarantined. Observability applies to the test suite too.

    A practical pipeline might run fast deterministic tests on every pull request, deeper integration tests before merge, and slower end-to-end or mutation checks on a schedule. Not every repository needs the same gates. A small plugin team and a large enterprise platform will make different tradeoffs, but both need confidence that passing CI means something.

    CI/CD itself is also becoming part of the agentic surface area. A 2026 arXiv study of 8,031 agentic pull requests across 1,605 GitHub repositories found that CI/CD configuration files accounted for 3.25% of agent changes, with most of those changes targeting GitHub Actions. That makes pipeline review part of the same quality conversation as test review.

    What This Means for WordPress and AI Plugin Teams

    WordPress teams building AI-enabled products face a particularly interesting version of this problem. Plugins often interact with databases, scheduled jobs, user roles, REST APIs, admin screens, external AI services, and third-party themes or plugins. That creates many places where an AI-generated test can look convincing while missing the real integration risk.

    For example, a team building an AI pipeline plugin for scheduled publishing, a chat assistant that escalates to a human, or a CRM plugin that enriches lead records should care about regression checks around permissions, rate limits, data persistence, cron behavior, and failure recovery. In a context like CoatiPress, reliable tests would not just confirm that an AI call was mocked successfully.

    Sources and Fact Check References

    • Anthropic – Anthropic’s 2026 Agentic Coding Trends Report describes software development as shifting toward orchestrating agents and discusses productivity, oversight, quality, and security tradeoffs.
    • Gartner – Gartner reported in May 2026 that the enterprise AI coding agent market was entering a phase of expansion and competitive realignment.
    • arXiv – A July 2026 arXiv paper analyzed 204,673 test artifacts from the AIDev dataset and reported higher candidate flakiness in agent-generated tests, largely tied to file I/O and nondeterministic logic.
    • arXiv – A 2026 arXiv study of 8,031 agentic pull requests across 1,605 GitHub repositories found that CI/CD configuration files accounted for 3.25% of agent changes, with most targeting GitHub Actions.
  • Before You Hand Work to an AI Coding Agent: A Practical Guardrail Checklist for Small Teams

    Before You Hand Work to an AI Coding Agent: A Practical Guardrail Checklist for Small Teams

    The Shift From Autocomplete to Agentic Development

    AI coding tools are moving beyond autocomplete. The important shift for small teams is not just that models can suggest a function faster; it is that coding agents can inspect a repository, plan a change, edit multiple files, run commands, summarize results, and sometimes prepare a pull request. Gartner described enterprise AI coding agents as part of a shift from AI-assisted development toward agentic software development across the software development life cycle, including planning, creating, and reviewing code.

    A coding agent, in plain language, is a software assistant that can take a development goal and perform steps toward it. Depending on the tool and configuration, it may read project files, modify code, run tests, use a terminal, search documentation, create commits, or draft a pull request for review. OpenAI describes Codex as a coding agent for real engineering work such as building features, refactors, migrations, and pull requests, while Anthropic describes Claude Code as an agentic assistant that can read code, edit files, run commands, search, and use git from a terminal workflow. That makes guardrails essential. The question is not whether an agent is useful. The question is what it is allowed to touch, how its work is verified, and who remains accountable.

    A Guardrail Checklist Before the Agent Edits Anything

    Small teams do not need enterprise bureaucracy to use coding agents responsibly. They do need a short, written checklist that turns vague trust into concrete controls. Before giving an agent repository access, decide which permissions, environments, and approval gates are required for each type of work.

    • Repository permissions: Start with the least access needed. Prefer read-only access for exploration tasks and limited write access for scoped implementation tasks. Do not give an agent broad organization-level permissions by default.
    • Sandboxing: Run agent-generated commands in a disposable local environment, development container, or isolated cloud workspace. The agent should not be able to alter production data, shared credentials, or developer machines without explicit approval.
    • Branch strategy: Require agents to work on short-lived feature branches with descriptive names. Avoid direct commits to main, release, or production branches.
    • Test coverage: Define the minimum verification bar before the task begins. For example, relevant unit tests must pass, integration tests must pass where applicable, and the agent must explain which tests it ran and which it did not run.
    • Secret handling: Never paste API keys, customer data, private tokens, database dumps, or production credentials into prompts. Use secret scanning and environment variables, and treat prompt history as information that may require governance.
    • Dependency-change review: Require human approval for package upgrades, new dependencies, lockfile changes, build tool changes, or generated code that introduces a new runtime requirement.
    • Prompt-instruction files: Maintain a project instruction file that states coding standards, testing commands, architectural boundaries, security expectations, and files the agent should not modify without approval.
    • Human approval gates: Require a human review before database migrations, authentication changes, payment logic, permissions logic, production configuration, release packaging, or changes to public APIs.
    • Logging and audit trails: Keep a record of what the agent was asked to do, what files it changed, what commands it ran, and which human approved the result. This matters when a regression appears later.
    • Rollback plans: Before merging agent-written changes, confirm the rollback path. That may mean a revertable pull request, a database migration rollback, a feature flag, or a staged release plan.

    Local, Cloud, and IDE-Integrated Agents: What Changes?

    Not all coding agents carry the same risk profile. A local agent runs close to a developer’s workstation and may have convenient access to project files and local tools. The OpenAI Codex repository describes Codex CLI as a coding agent that runs locally on a user’s computer, and Anthropic’s Claude Code documentation says local execution gives the agent access to the user’s files, tools, and environment. That can be fast, but teams must be careful about shell access, environment variables, and unreviewed command execution.

    A cloud agent can work in an isolated or managed environment and may be easier to audit, but it raises questions about repository permissions, data exposure, network access, and log retention. An IDE-integrated agent sits inside a familiar coding workflow, which lowers friction but can encourage developers to accept changes too quickly. The practical rule is simple: match the agent environment to the risk of the task. Asking an agent to rename a UI component, add inline documentation, or draft tests may require lighter controls. Asking it to change authentication, perform a schema migration, modify permissions, or alter a release workflow requires stronger isolation, explicit approvals, and a rollback plan.

    A WordPress Plugin Example

    Imagine a small team working on a WordPress plugin admin screen. A well-scoped agent task might be: “Refactor the settings page into smaller view components, preserve the existing option names, do not add new dependencies, and run the plugin’s PHP and JavaScript tests.” That prompt gives the agent a useful target while setting boundaries around compatibility and package changes.

    The team should still keep higher-risk work under human review. Database migrations, option schema changes, user capability checks, release packaging, WordPress.org readme updates, and deployment steps should not be silently delegated. For an AI-first software company such as CoatiPress, which builds products in the WordPress ecosystem, these guardrails are especially relevant: the faster the tools become, the more important it is to preserve quality, security, and clear ownership.

    What to Put in an Agent Instruction File

    A project-level instruction file is one of the simplest ways to improve agent output. Claude Code documentation describes CLAUDE.md as a markdown file for project-specific instructions, conventions, and context, and the Codex repository itself includes an AGENTS.md file, reflecting the broader pattern of storing agent guidance in the repository. Keep the file short enough that developers will maintain it, but specific enough that the agent can follow it.

    • State the project stack, supported language versions, package managers, and required local services.
    • List the commands for formatting, linting, unit tests, integration tests, builds, and static analysis.
    • Define protected areas such as migrations, release scripts, payment code, authentication code, permissions logic, and production configuration.
    • Explain code style preferences that are not obvious from existing files.
    • Require the agent to summarize changed files, tests run, assumptions made, and remaining risks.
    • Tell the agent when to stop and ask for human approval instead of continuing.

    The Review Standard Should Not Drop Because an Agent Wrote It

    Agent-written code should go through the same review path as human-written code, and sometimes a stricter one. Reviewers should look for plausible but wrong assumptions, unnecessary abstractions, silent behavior changes, hidden dependency updates, weak error handling, and missing tests. The best review question is not “Did AI write this?” It is “Is this change correct, maintainable, secure, and reversible?”

    Teams should also watch for automation bias. When an agent produces a polished summary, the work can feel more complete than it really is. Require evidence: test output, diffs, screenshots for UI changes, migration notes, and a clear explanation of tradeoffs. A confident paragraph is not a substitute for verification.

    A Balanced Takeaway for Small Teams

    Coding agents can accelerate repetitive development work, reduce blank-page friction, and help small teams move through maintenance tasks faster. But they are not magic coworkers, and they do not remove accountability from the people shipping the product. The safest teams will treat agents as powerful contributors operating inside explicit boundaries: limited permissions, isolated environments, strong tests, careful secret handling, human approvals, audit trails, and rollback plans.

    The goal is not to slow everyone down. The goal is to make speed repeatable. When guardrails are clear, developers can hand off appropriate tasks with confidence, reviewers can verify the result, and founders can adopt AI-first workflows without turning their codebase into an experiment with no safety net.

    Sources and Fact Check References

    • Gartner – Gartner described enterprise AI coding agents as part of a shift from AI-assisted development toward agentic software development across the software development life cycle, including planning, creating, and reviewing code.
    • OpenAI Codex – OpenAI describes Codex as a coding agent for real engineering work such as building features, refactors, migrations, and pull requests.
    • OpenAI Codex GitHub repository – The OpenAI Codex GitHub repository describes Codex CLI as a coding agent that runs locally on a user's computer.
    • Anthropic Claude Code documentation – Anthropic documentation says Claude Code can read code, edit files, run commands, use git, and operate across local, cloud, and remote-control execution environments.
    • Anthropic Claude Code documentation – Anthropic documentation describes CLAUDE.md as a markdown file for project-specific instructions, conventions, and context that Claude should know in each session.