{"slug": "measuring-ai-agent-readiness-in-a-typescript-codebase", "title": "Measuring AI Agent Readiness in a TypeScript Codebase", "summary": "A developer proposes a framework for measuring \"AI agent readiness\" in TypeScript codebases, arguing that traditional code quality metrics like test coverage and complexity don't capture whether a coding agent can safely understand and modify a project. The approach combines objective tooling evidence from the TypeScript compiler, typescript-eslint, type-coverage and tsd with LLM interpretation, and examines strict type configuration, runtime validation of untrusted data at system boundaries using libraries such as Zod, Valibot, TypeBox and Ajv, and executable architecture rules.", "body_md": "AI is changing the economics of software development.\n\nWhen code generation becomes cheaper, the ability to verify generated code becomes increasingly important. This changes how we should think about software architecture, type systems, testing and CI/CD.\n\nA codebase that is easy for an experienced developer to understand is not necessarily easy for an AI agent to work with. Similarly, a codebase with high test coverage is not necessarily a codebase in which an agent can safely make changes.\n\nWe need to think beyond code quality.\n\nWe need to think about **AI agent readiness**.\n\nBut what does that actually mean? And how could we measure it?\n\nTraditional code quality assessments tend to focus on properties such as maintainability, complexity, duplication, test coverage and security.\n\nThese properties remain important, but they don't tell us the whole story.\n\nAn AI coding agent needs to do more than generate code. It needs to:\n\nThis introduces a different set of questions.\n\nCan an agent understand the architecture without reconstructing it from thousands of files?\n\nCan it determine whether a dependency violates an architectural boundary?\n\nCan it distinguish between a meaningful test and a test that simply executes code?\n\nCan it detect when its implementation is incorrect?\n\nMost importantly, can it independently establish that its work is complete?\n\nThese questions suggest that AI agent readiness is a property of the entire software development environment, not simply the source code.\n\nLet's explore how we could evaluate it in a TypeScript codebase.\n\nThe TypeScript compiler is one of the most important verification tools available to an AI agent.\n\nTypes communicate intent. They describe contracts, constrain implementations and make certain categories of mistakes detectable before runtime.\n\nHowever, simply using TypeScript doesn't mean that a codebase has a strong type system.\n\nConsider the following configuration:\n\n```\n{\n  \"compilerOptions\": {\n    \"strict\": false,\n    \"noImplicitAny\": false,\n    \"strictNullChecks\": false\n  }\n}\n```\n\nThis provides relatively few guarantees.\n\nA readiness assessment should examine:\n\n`any`.` unknown` at external boundaries.\nTools such as TypeScript, typescript-eslint, type-coverage and tsd can provide much of the objective evidence.\n\nThe LLM's role is to interpret that evidence and identify places where the type system communicates less intent than it should.\n\nFor example, an agent should be able to distinguish between a legitimate type assertion at a trusted boundary and an assertion that simply suppresses a type error.\n\nThe objective isn't to eliminate every type assertion. It's to understand where the codebase relies on assumptions rather than guarantees.\n\nTypeScript types disappear at runtime.\n\nAn API response, environment variable, database result or message from a queue doesn't become trustworthy simply because it has been assigned a TypeScript interface.\n\nConsider:\n\n``` js\ninterface User {\n  id: string;\n  email: string;\n}\n\nconst user = await response.json() as User;\n```\n\nThe compiler accepts this, but nothing guarantees that the response actually represents a valid User.\n\nA readiness assessment should investigate whether untrusted data is validated at system boundaries.\n\nThis includes:\n\nIt should also examine whether runtime schemas and TypeScript types remain consistent.\n\nLibraries such as Zod, Valibot, TypeBox and Ajv can help establish explicit runtime contracts.\n\nThe important question is whether an agent can determine where data enters the system and what guarantees are established before that data is used.\n\nArchitecture is often documented through conventions, diagrams and developer knowledge.\n\nUnfortunately, conventions are easy to violate, particularly when an AI agent is modifying unfamiliar parts of a codebase.\n\nArchitecture should therefore be executable wherever possible.\n\nFor example, consider a layered architecture:\n\n```\nPresentation\n     |\nApplication\n     |\nDomain\n     |\nInfrastructure\n```\n\nThe intended dependency direction might be:\n\n``` php\nPresentation -> Application -> Domain\nInfrastructure -> Application / Domain\n```\n\nAn agent should be able to discover these rules and verify that the actual dependency graph respects them.\n\nA readiness assessment should check:\n\nTools such as dependency-cruiser, Madge, ESLint boundaries, Nx module boundaries and ArchUnitTS can make these rules executable.\n\nConsider this dependency-cruiser configuration:\n\n```\n{\n  name: 'domain-must-not-depend-on-infrastructure',\n  from: {\n    path: '^src/domain'\n  },\n  to: {\n    path: '^src/infrastructure'\n  }\n}\n```\n\nThe specific configuration will vary, but the principle is important.\n\nAn architectural decision should ideally be represented by an automated constraint rather than relying exclusively on documentation.\n\nFor an AI agent, this turns architectural intent into something it can verify.\n\nTest coverage is useful, but it is a relatively weak indicator of test quality.\n\nA test can execute every line of a function without verifying that the function behaves correctly.\n\nAn agent readiness assessment should examine:\n\nIt should also inspect critical business logic separately from the overall coverage percentage.\n\nFor example, 90% overall coverage might look impressive, but what happens if the most important pricing calculation has no meaningful tests?\n\nThe objective is not simply to establish whether code is executed. It is to establish whether incorrect behaviour is detected.\n\nMutation testing is particularly interesting in the context of AI-generated code.\n\nIt addresses a question that ordinary coverage cannot answer:\n\n**Would the tests detect an incorrect implementation?**\n\nMutation testing tools deliberately introduce small changes into the source code.\n\nFor example:\n\n```\nfunction isEligible(age: number): boolean {\n  return age >= 18;\n}\n```\n\nA mutation might change the comparison:\n\n```\nfunction isEligible(age: number): boolean {\n  return age > 18;\n}\n```\n\nIf the test suite still passes, it may not adequately cover the boundary condition.\n\nAn assessment should examine:\n\nStrykerJS is an excellent tool for mutation testing in TypeScript projects.\n\nI would pay particular attention to mutation scores for critical business logic rather than relying exclusively on one aggregate percentage.\n\nA codebase might have excellent overall mutation results while important business rules remain insufficiently protected.\n\nUnit tests cannot establish that independently correct components work correctly together.\n\nAn agent needs confidence in the contracts between modules and external systems.\n\nThe assessment should investigate:\n\nTools such as Testcontainers, Pact, MSW, Supertest and Playwright can provide executable evidence", "url": "https://wpnews.pro/news/measuring-ai-agent-readiness-in-a-typescript-codebase", "canonical_source": "https://dev.to/remojansen/measuring-ai-agent-readiness-in-a-typescript-codebase-280f", "published_at": "2026-12-06 22:08:07+00:00", "updated_at": "2026-12-06 22:14:21.664093+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools", "large-language-models"], "entities": ["TypeScript", "typescript-eslint", "type-coverage", "tsd", "Zod", "Valibot", "TypeBox", "Ajv"], "also_reported_by": [], "takeaway": "Assess agent readiness by combining compiler and lint evidence (strict flags, type-coverage, tsd) with runtime schema validation at system boundaries, since TypeScript types vanish at runtime and `as User` on a fetch response guarantees nothing.", "recommendation": {"advice": "Before letting coding agents modify a TypeScript repo, enable strict compiler flags, validate untrusted data at boundaries with Zod or Valibot, and make architectural boundaries executable so agents can verify their own work.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/measuring-ai-agent-readiness-in-a-typescript-codebase", "markdown": "https://wpnews.pro/news/measuring-ai-agent-readiness-in-a-typescript-codebase.md", "text": "https://wpnews.pro/news/measuring-ai-agent-readiness-in-a-typescript-codebase.txt", "jsonld": "https://wpnews.pro/news/measuring-ai-agent-readiness-in-a-typescript-codebase.jsonld"}}