[Bug] Agents Violate TypeScript Error Remediation Instructions

Resolved 💬 3 comments Opened Aug 31, 2025 by feyazbek Closed Jan 5, 2026

Bug Description
Bug Report: Agents Ignoring Instructions and Introducing TypeScript Errors
Description

Agents in Claude Code are ignoring provided instructions during TypeScript error remediation. Instead of fixing existing errors, they created fake test files, imported non-existent functions, and produced false success reports, resulting in more errors overall.

Despite instructions and validator files (preflight-validator.md, GLOBAL_LIMITS.md), these safeguards are not enforced. The agents treat them as advisory, not mandatory.

Evidence from Session

Initial State: ~1150 TypeScript errors

Claimed by Agents: 300+ errors fixed, 67% reduction in chatbot-secure, 27% in admin_ui

Actual Result: Only 36 errors fixed (1150 → 1116, a 3.1% reduction).

Deception:

Agents created new test files importing non-existent exports (sanitizeConfigInput, mergeConfigWithDefaults, etc.)

Agents reported “success” without validation proof.

Errors were not reduced—hundreds of new errors introduced.

Example: chatbot-secure was claimed as “126 → ~40 errors” but actually had 622 errors.

Root Cause

No enforcement of agent rules (validator files are not executed, only documented).

No automatic verification of TypeScript fixes (npm run type-check never enforced).

False reporting allowed (agents claim fixes without proof).

Creation of new files caused hundreds of new TypeScript errors.

Expected Behavior

Agents must only fix existing errors in existing files.

Agents must run validation (npm run type-check) before and after changes.

Agents must not create new files during error fixes.

All claims of “error reduction” must be backed by before/after error counts.

Actual Behavior

Agents ignored instructions and safeguards.

Added fake test/business logic files.

Increased error counts instead of reducing them.

Reported false progress and success.

Steps to Reproduce

Run any remediation task using agents (bug-hunter, pattern-compliant-test-generator).

Provide instructions to fix TypeScript errors.

Observe:

New broken test files are created.

Imports reference non-existent functions.

Error counts increase or barely change.

Agents claim massive error reductions without validation proof.

Impact

Codebase destabilized.

Error count remains essentially unchanged (~1116 errors).

Hundreds of new errors introduced.

False reporting creates trust issues in remediation process.

Suggested Fix

Enforce instructions programmatically, not just in .md documentation.

Add a wrapper system that:

Runs npm run type-check before and after agent tasks.

Rolls back changes if error counts increase.

Rejects any new file creation during TypeScript error remediation.

Requires explicit before/after error count proof.

Integrate validation into the agent execution system rather than relying on agents to self-police.

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 1.0.96
  • Feedback ID: 5656b294-2c57-4293-8c13-56171f5f5a71

Errors

[{"error":"SyntaxError: Unexpected token '/', \"/Users/ey/\"... is not valid JSON\n    at JSON.parse (<anonymous>)\n    at file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:704:9932\n    at Q (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:671:13288)\n    at GP0.<anonymous> (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:3639:218)\n    at GP0.B [as _actionHandler] (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:661:528)\n    at file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:665:3127\n    at GP0._chainOrCall (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:665:1694)\n    at GP0._parseCommand (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:665:3103)\n    at GP0.parseAsync (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:662:4195)\n    at jS5 (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:3671:1224)","timestamp":"2025-08-29T14:50:35.393Z"},{"error":"Error: ENOENT: no such file or directory, scandir '/Users/ey/Documents/chatbot_copy/sharepoint-graph-crawler'\n    at Module.readdirSync (node:fs:1507:26)\n    at Object.readdirSync (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:683:12285)\n    at eb6 (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:1907:721)\n    at Object.call (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:1907:148)\n    at call.next (<anonymous>)\n    at vM5 (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/node_modules/@anthropic-ai/claude-code/cli.js:3529:11340)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async EmB (file:///Users/ey/.nvm/versions/node/v20.18.3/lib/nod

Note: Error logs were truncated.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗