[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E0KER5SHGS2V2ZMCNR307Y":3,"skill-same:01M6E0KER5SHGS2V2ZMCNR307Y":84},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":33,"linkOnly":34,"markdownContent":35,"markdownBody":36,"frontMatter":37,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":14,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":43,"ownerDescription":44,"updatedAt":45,"install":46,"resources":59},"01M6E0KER5SHGS2V2ZMCNR307Y","agent-gotchas",null,"AI coding agents fail in consistent, predictable ways. They fabricate npm packages that don't exist. They catch errors and continue silently. They add features you never asked for. They lose context mid-session and forget what they were doing.","LucasSantana-Dev\u002Fforgekit","LucasSantana-Dev","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F98131142?v=4","01M6E038X8H7VE9GCEJP9PT5CA","Lucas Santana","01M6E0391WB0JYZTWXEBR9WSXA",1,"MIT","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcatalog\u002Fcatalog\u002Fskills\u002Fagent-gotchas\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32],"agent gotchas","coding agents","ai coding agents","packages","npm","continue","coding","context","session","never","ai coding","Fabricate","forget","add","2026-11-10 10:12:30",false,"---\nname: agent-gotchas\ndescription: >-\n  AI coding agents fail in consistent, predictable ways. They fabricate npm\n  packages that don't exist. They catch errors and continue silently. They add\n  features you never asked for. They lose context mid-session and forget what\n  they were doing.\n---\n# AI Agent Gotchas\n\n> AI agents are powerful but predictably unreliable. Know their failure modes.\n\n## The Problem\n\nAI coding agents fail in consistent, predictable ways. They fabricate npm packages that don't exist. They catch errors and continue silently. They add features you never asked for. They lose context mid-session and forget what they were doing.\n\nThese aren't bugs—they're fundamental characteristics of LLM-based agents. You can't fix them, but you can work around them.\n\nThe insight: AI agents are reliable tools with unreliable execution. Build guardrails, verify outputs, and design workflows that assume failure.\n\n## The Pattern\n\n### 1. Atomic Edits for Multi-File Changes\n\n**Problem:** AI tools like Edit or Write run individually. If you make 5 file changes, there are 5 separate tool calls. Between tool calls, hooks can run, other sessions can interfere, or the agent can lose context.\n\n**Example failure:**\n```\nAgent: \"I'll update 3 files for the auth feature\"\n[Edit file1.ts] ✓\n[PostToolUse hook runs, reformats file1.ts]\n[Edit file2.ts] ✓\n[Another session force-pushes, rebases branch]\n[Edit file3.ts] ✗ Fails, branch state changed\n\nResult: Partial implementation, inconsistent state\n```\n\n**Solution: Single-transaction pattern**\n\nUse a shell script to make all changes atomically:\n\n```bash\npython3 \u003C\u003C 'EOF'\nimport json\n\n# Read all files\nwith open('file1.ts', 'r') as f:\n    file1 = f.read()\nwith open('file2.ts', 'r') as f:\n    file2 = f.read()\nwith open('file3.ts', 'r') as f:\n    file3 = f.read()\n\n# Make all changes\nfile1 = file1.replace('old1', 'new1')\nfile2 = file2.replace('old2', 'new2')\nfile3 = file3.replace('old3', 'new3')\n\n# Write all files\nwith open('file1.ts', 'w') as f:\n    f.write(file1)\nwith open('file2.ts', 'w') as f:\n    f.write(file2)\nwith open('file3.ts', 'w') as f:\n    f.write(file3)\nEOF\n\n# Atomic commit\ngit add file1.ts file2.ts file3.ts\ngit commit -m \"feat: implement auth feature\"\n```\n\n**Why this works:**\n- All file changes happen in one tool call (Bash)\n- Hooks run once at the end, not between edits\n- Other sessions can't interfere mid-edit\n- Agent can't lose context between files\n\n**When to use:**\n- Multi-file refactors (renaming, moving functions)\n- Feature implementation spanning multiple modules\n- Migration scripts (updating all files to new pattern)\n- Any change where partial completion is invalid\n\n### 2. Hook Interference\n\n**Problem:** PostToolUse hooks (Prettier, ESLint --fix, formatters) can revert agent changes.\n\n**Example failure:**\n```typescript\n\u002F\u002F Agent edits file to add function\nexport function newFeature() {\n  return \"value\"\n}\n\n\u002F\u002F PostToolUse hook runs Prettier\n\u002F\u002F Prettier removes \"unused\" import the function depends on\nimport { dependency } from '.\u002Flib';  \u002F\u002F REMOVED by hook\nexport function newFeature() {\n  return \"value\"  \u002F\u002F Now broken, missing dependency\n}\n```\n\n**Solution: Disable hooks for multi-step changes**\n\n```bash\n# Disable hooks temporarily\nexport SKIP_HOOKS=1\n\n# Make changes\n# ... agent edits files ...\n\n# Re-enable and run manually\nunset SKIP_HOOKS\nnpm run format\nnpm run lint:fix\ngit add .\ngit commit -m \"feat: add feature\"\n```\n\n**Or: Verify after each change**\n\n```bash\n# After agent edits\ngit diff  # Verify change is what you expect\nnpm run format  # Run formatters manually\ngit diff  # Verify formatters didn't break anything\ngit add .\ngit commit -m \"feat: add feature\"\n```\n\n**Where hooks interfere:**\n- Prettier removing \"unused\" code that's about to be used\n- ESLint auto-fixing away intentional patterns\n- TypeScript auto-imports conflicting with manual imports\n- Git hooks rejecting commits mid-workflow\n\n### 3. Session Interference\n\n**Problem:** Multiple AI sessions working on the same repository switch branches, force-push, or close PRs between each other's tool calls.\n\n**Example failure:**\n```\nSession A (Terminal 1):\n  [List files in feature\u002Fauth] ✓\n  [Read auth.ts] ✓\n\nSession B (Terminal 2):\n  git checkout main\n  git branch -D feature\u002Fauth\n  git push origin :feature\u002Fauth\n\nSession A (Terminal 1):\n  [Edit auth.ts] ✗ Error: branch 'feature\u002Fauth' not found\n```\n\n**Solution: Use worktrees for isolation**\n\n```bash\n# Session A\ngit worktree add ~\u002F.claude\u002Fworktrees\u002Fsession-a feature\u002Fauth\ncd ~\u002F.claude\u002Fworktrees\u002Fsession-a\n# Work here, fully isolated\n\n# Session B\ngit worktree add ~\u002F.claude\u002Fworktrees\u002Fsession-b feature\u002Fpayments\ncd ~\u002F.claude\u002Fworktrees\u002Fsession-b\n# Work here, can't interfere with Session A\n```\n\nSee [git-worktrees.md](git-worktrees.md) for full pattern.\n\n**Worktree isolation prevents:**\n- Branch switching mid-task\n- Force-push overwrites\n- PR closures breaking other sessions\n- Merge conflicts from simultaneous edits\n\n### 4. Context Window Overflow\n\n**Problem:** Long AI sessions accumulate context (files read, commands run, conversation history). After 100K+ tokens, early context is lost. Agent forgets project structure, coding standards, or what it was doing.\n\n**Example failure:**\n```\nEarly in session:\n  You: \"Use functional components, no classes\"\n  Agent: \"Got it, functional components only\"\n\n50 files later:\n  Agent: \"I'll create a class component for this feature\"\n  You: \"I said no classes!\"\n  Agent: \"Sorry, I don't see that instruction in our conversation\"\n```\n\n**Solution: Proactive context save**\n\nAt ~70% context usage (~140K tokens), save state:\n\n```bash\n# Save current progress\ncat > .claude\u002Fin-progress.md \u003C\u003C EOF\n# Auth Feature Implementation\n\n## Completed\n- [x] User model with email\u002Fpassword\n- [x] JWT generation utility\n- [x] Login endpoint\n\n## In Progress\n- [ ] Password reset flow\n- [ ] Email verification\n\n## Coding Standards\n- Functional components only\n- Functions \u003C 50 lines\n- Zod for validation (pattern: @lib\u002Fvalidators\u002Fuser.ts)\n\n## Next Steps\n1. Implement password reset token generation\n2. Add email sending service\n3. Create reset verification endpoint\nEOF\n\n# Compress context\n\u002Fcompact\n\n# Resume with loaded context\ncat .claude\u002Fin-progress.md\n# Continue work with fresh context window\n```\n\n**Automated context monitoring:**\n```bash\n# Add to shell prompt\nfunction context_usage() {\n  # Estimate based on conversation length\n  if [ -f .claude\u002Fcontext-estimate ]; then\n    cat .claude\u002Fcontext-estimate\n  fi\n}\n\nPS1='[$(context_usage)] $ '\n```\n\n### 5. Fabricated Metrics\n\n**Problem:** AI agents invent statistics, npm download counts, GitHub stars, or performance numbers when they don't have real data.\n\n**Example fabrication:**\n```markdown\n## Our Library\n\n- 100K+ npm downloads\u002Fmonth ?\n- 5K+ GitHub stars ⭐\n- 95% test coverage ✅\n- Used by companies like Google, Netflix, Uber\n\n(All numbers made up by AI)\n```\n\n**Real data:**\n- 47 npm downloads\u002Fmonth\n- 12 GitHub stars\n- 60% test coverage\n- No known enterprise users\n\n**Solution: Use dynamic badges with real data**\n\n```markdown\n## Our Library\n\n![npm downloads](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fdm\u002F@scope\u002Fpackage)\n![GitHub stars](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fuser\u002Frepo)\n![coverage](https:\u002F\u002Fimg.shields.io\u002Fcodecov\u002Fc\u002Fgithub\u002Fuser\u002Frepo)\n\n\u003C!-- Badges auto-update with real data -->\n```\n\n**Or: Fetch real metrics**\n\n```bash\n# Get npm downloads\nnpm_downloads=$(curl -s https:\u002F\u002Fapi.npmjs.org\u002Fdownloads\u002Fpoint\u002Flast-month\u002F@scope\u002Fpackage | jq '.downloads')\n\n# Get GitHub stars\ngh_stars=$(gh api repos\u002Fuser\u002Frepo --jq '.stargazers_count')\n\n# Update README with real data\nsed -i \"s\u002FDOWNLOADS_PLACEHOLDER\u002F$npm_downloads\u002Fg\" README.md\nsed -i \"s\u002FSTARS_PLACEHOLDER\u002F$gh_stars\u002Fg\" README.md\n```\n\n**Never trust agent-provided:**\n- Download counts, star counts, popularity metrics\n- Performance benchmarks (unless you ran them)\n- User testimonials or case studies\n- \"Industry standard\" claims\n\n**Always verify:**\n- npm API for download counts\n- GitHub API for stars\u002Fforks\n- Your own analytics for user counts\n- Actual benchmarks for performance\n\n### 6. Dependency Hallucination\n\n**Problem:** AI suggests packages that don't exist, outdated APIs, or deprecated libraries.\n\n**Example hallucination:**\n```typescript\n\u002F\u002F Agent suggestion\nimport { validateEmail } from '@utils\u002Femail-validator';\nimport { formatDate } from 'date-fns\u002Fformat';\nimport { parseJWT } from 'jwt-helper';\n\n\u002F\u002F Reality\n\u002F\u002F @utils\u002Femail-validator - doesn't exist\n\u002F\u002F date-fns\u002Fformat - wrong import path (should be 'date-fns')\n\u002F\u002F jwt-helper - package doesn't exist (maybe meant 'jsonwebtoken'?)\n```\n\n**Solution: Verify every new dependency**\n\n```bash\n# Before installing agent-suggested package\nnpm info \u003Cpackage-name>\n\n# Check if it exists, last publish date, version\n# If \"ERR! 404 Not Found\": package doesn't exist\n\n# Check actual API\nnpm info \u003Cpackage-name> exports\n# Or read the package README\n```\n\n**Red flags:**\n- Package name too generic (`email-validator`, `jwt-helper`)\n- No npm downloads\u002Fweek listed\n- Last publish > 2 years ago\n- No GitHub link or documentation\n\n**Safer approach:**\n```\nYou: \"I need to validate emails\"\nAgent: \"Use @utils\u002Femail-validator\"\nYou: \"Does this package exist? Check npm API first\"\nAgent: [checks] \"Package doesn't exist. Use 'validator' instead (2M downloads\u002Fweek)\"\n```\n\n### 7. Over-Engineering\n\n**Problem:** AI agents add features you didn't ask for: caching, logging, metrics, retry logic, feature flags, etc.\n\n**Example over-engineering:**\n```typescript\n\u002F\u002F You asked for: \"Add a function to get user by ID\"\n\n\u002F\u002F Agent delivers:\nasync function getUser(\n  id: string,\n  options: {\n    cache?: boolean;\n    cacheTTL?: number;\n    retry?: number;\n    timeout?: number;\n    includeDeleted?: boolean;\n    includeMetadata?: boolean;\n  } = {}\n): Promise\u003CUser> {\n  const cacheKey = `user:${id}`;\n\n  if (options.cache) {\n    const cached = await redis.get(cacheKey);\n    if (cached) {\n      logger.info('Cache hit', { userId: id });\n      return JSON.parse(cached);\n    }\n  }\n\n  let attempts = 0;\n  while (attempts \u003C (options.retry || 3)) {\n    try {\n      const user = await db.users.findById(id, {\n        includeDeleted: options.includeDeleted,\n        timeout: options.timeout || 5000\n      });\n\n      if (options.cache) {\n        await redis.set(cacheKey, JSON.stringify(user), 'EX', options.cacheTTL || 300);\n      }\n\n      logger.info('User fetched', { userId: id, attempts });\n      metrics.increment('user.fetch.success');\n\n      return user;\n    } catch (err) {\n      attempts++;\n      logger.error('User fetch failed', { userId: id, attempt: attempts, error: err });\n      metrics.increment('user.fetch.error');\n\n      if (attempts >= (options.retry || 3)) {\n        throw err;\n      }\n    }\n  }\n}\n\n\u002F\u002F You needed:\nasync function getUser(id: string): Promise\u003CUser> {\n  return db.users.findById(id);\n}\n```\n\n**Solution: Constrain scope explicitly**\n\n```\nAdd a function to get user by ID.\n\nRequirements:\n- Input: user ID (string)\n- Output: User object or throw NotFoundError\n- Implementation: Call db.users.findById()\n- NO caching, NO retry logic, NO logging, NO metrics\n- \u003C 10 lines\n\nExample:\nasync function getUser(id: string): Promise\u003CUser> {\n  const user = await db.users.findById(id);\n  if (!user) throw new NotFoundError('User not found');\n  return user;\n}\n```\n\n**Red flags for over-engineering:**\n- Function is 3x longer than expected\n- Added dependencies you didn't ask for\n- Options object with 5+ parameters\n- Feature flags for simple behavior\n- Caching\u002Fretry\u002Fcircuit-breaker for non-critical path\n\n### 8. Silent Failures\n\n**Problem:** AI agents catch errors and continue silently, hiding failures.\n\n**Example silent failure:**\n```typescript\nasync function processOrders(orders: Order[]) {\n  for (const order of orders) {\n    try {\n      await processOrder(order);\n    } catch (err) {\n      \u002F\u002F Agent added this silently\n      console.log('Failed to process order', err);\n      \u002F\u002F Continues to next order, no error thrown\n    }\n  }\n  return { success: true };  \u002F\u002F Lies!\n}\n\n\u002F\u002F Result: Some orders failed, but caller thinks all succeeded\n```\n\n**Solution: Explicit error handling strategy**\n\n```\nImplement processOrders(orders):\n- Process each order\n- On error: collect failed orders, don't stop processing\n- Return: { processed: Order[], failed: { order: Order, error: string }[] }\n- Let caller decide how to handle failures\n\nDO NOT catch and ignore errors silently.\n```\n\n**Better implementation:**\n```typescript\nasync function processOrders(orders: Order[]) {\n  const processed: Order[] = [];\n  const failed: { order: Order; error: string }[] = [];\n\n  for (const order of orders) {\n    try {\n      await processOrder(order);\n      processed.push(order);\n    } catch (err) {\n      failed.push({ order, error: err.message });\n    }\n  }\n\n  return { processed, failed };\n}\n```\n\n**Watch for:**\n- Try\u002Fcatch with only console.log\n- Errors caught but not re-thrown or returned\n- Success response when partial failure occurred\n- Missing error details in response\n\n### 9. Test Data Pollution\n\n**Problem:** AI-generated tests use unrealistic data that passes tests but fails in production.\n\n**Example bad test data:**\n```typescript\nit('creates user', async () => {\n  const user = await createUser({\n    email: 'test@test.com',\n    name: 'Test User',\n    age: 99\n  });\n\n  expect(user.id).toBeDefined();\n});\n\n\u002F\u002F Production failure:\n\u002F\u002F Real user \"María José García-López\" with email \"maria.jose@empresa.com\"\n\u002F\u002F Name validation rejects special characters!\n```\n\n**Solution: Realistic test data**\n\n```typescript\nit('creates user with international characters', async () => {\n  const user = await createUser({\n    email: 'maria.jose@empresa.com',\n    name: 'María José García-López',\n    age: 34\n  });\n\n  expect(user.id).toBeDefined();\n  expect(user.name).toBe('María José García-López');\n});\n```\n\n**Require realistic test data:**\n```\nGenerate tests for createUser.\n\nTest data requirements:\n- Real names (not \"Test User\", \"John Doe\", \"foo bar\")\n- Real email domains (not test.com, example.com)\n- International characters (María, 北京, Müller)\n- Edge cases (very long names, special characters, numbers)\n\nExamples of good test data:\n- \"Sarah Chen\", \"sarah.chen@company.com\"\n- \"José García\", \"jose.garcia@startup.io\"\n- \"李明\", \"liming@tech.cn\"\n```\n\n### 10. Configuration Drift\n\n**Problem:** Agent creates `.env.example` but doesn't update actual `.env`, or vice versa.\n\n**Example drift:**\n```bash\n# .env.example (what agent updated)\nDATABASE_URL=postgresql:\u002F\u002Flocalhost\u002Fmyapp\nREDIS_URL=redis:\u002F\u002Flocalhost:6379\nJWT_SECRET=your-secret-here\nNEW_FEATURE_FLAG=true  # Agent added this\n\n# .env (what's actually used)\nDATABASE_URL=postgresql:\u002F\u002Flocalhost\u002Fmyapp\nREDIS_URL=redis:\u002F\u002Flocalhost:6379\nJWT_SECRET=prod-secret\n# NEW_FEATURE_FLAG missing! Feature doesn't work.\n```\n\n**Solution: Sync config files**\n\n```\nAdd NEW_FEATURE_FLAG to environment config.\n\nUpdate BOTH files:\n1. .env.example (with placeholder value)\n2. .env (with actual value or prompt me for it)\n\nAfter updating, verify they have the same keys:\n```bash\ndiff \u003C(grep '^[A-Z]' .env | cut -d= -f1 | sort) \u003C(grep '^[A-Z]' .env.example | cut -d= -f1 | sort)\n```\n\nIf diff shows missing keys, update both files.\n```\n\n**Automated sync check:**\n```bash\n# add to CI\nnpm run config-check\n\n# package.json\n{\n  \"scripts\": {\n    \"config-check\": \"node scripts\u002Fcheck-env-sync.js\"\n  }\n}\n\n\u002F\u002F scripts\u002Fcheck-env-sync.js\nconst fs = require('fs');\n\nconst env = fs.readFileSync('.env', 'utf8');\nconst example = fs.readFileSync('.env.example', 'utf8');\n\nconst envKeys = env.match(\u002F^[A-Z_]+=\u002Fgm)?.map(k => k.slice(0, -1)) || [];\nconst exampleKeys = example.match(\u002F^[A-Z_]+=\u002Fgm)?.map(k => k.slice(0, -1)) || [];\n\nconst missing = exampleKeys.filter(k => !envKeys.includes(k));\nif (missing.length > 0) {\n  console.error('Missing in .env:', missing);\n  process.exit(1);\n}\n```\n\n## Anti-Patterns\n\n### 1. Trusting Agent Memory\n\n**Bad:**\n```\nSession start:\n  You: \"Use TypeScript strict mode and Zod validation\"\n  Agent: \"Got it\"\n\n2 hours later:\n  Agent: *generates code with implicit any and no validation*\n  You: \"I told you to use strict mode!\"\n  Agent: \"I don't recall that instruction\"\n```\n\n**Why bad:** Context window is limited. Early instructions are forgotten.\n\n**Fix:**\n```\nCreate .claude\u002Fstandards.md:\n\n# Coding Standards\n- TypeScript strict mode (no implicit any)\n- Zod for all input validation\n- Functions \u003C 50 lines\n- No classes, use functional components\n\nReference this file at start of each session:\n\"Follow the standards in .claude\u002Fstandards.md\"\n```\n\n### 2. No Verification After Agent Changes\n\n**Bad:**\n```\nAgent: \"I've updated the database schema\"\nYou: \"Great, thanks!\"\n[deploys to production]\n[production crashes - migration broke]\n```\n\n**Why bad:** Agent might have made incorrect changes, broken migrations, or missed edge cases.\n\n**Fix:**\n```\nAgent: \"I've updated the database schema\"\nYou: \"Show me the diff\"\n[Review changes]\nYou: \"Run the migration on a test database first\"\n[Verify it works]\nYou: \"Run rollback test\"\n[Verify rollback works]\nYou: \"Now deploy to production\"\n```\n\n### 3. Accepting First Solution\n\n**Bad:**\n```\nYou: \"How do I cache API responses?\"\nAgent: \"Use an in-memory Map\"\nYou: \"Okay\" [implements in-memory cache]\n[Doesn't scale, memory leak in production]\n```\n\n**Why bad:** Agent gives first solution that pops up, not best solution.\n\n**Fix:**\n```\nYou: \"How do I cache API responses? List 3 options with tradeoffs\"\nAgent:\n  1. In-memory Map (fast, doesn't scale across servers, memory leak risk)\n  2. Redis (scales, adds latency, requires infrastructure)\n  3. CDN caching (fastest, limited control, only for public data)\n\nYou: \"We have Redis already. Use option 2\"\n```\n\n### 4. Not Constraining Output Size\n\n**Bad:**\n```\nYou: \"Generate tests for UserService\"\nAgent: [generates 500 tests, 3000 lines, covers every possible permutation]\n```\n\n**Why bad:** Too many tests = slow CI, hard to maintain, diminishing returns.\n\n**Fix:**\n```\nYou: \"Generate 10 critical tests for UserService\"\n- Happy path (1 test)\n- Validation errors (3 tests)\n- Permission errors (2 tests)\n- Edge cases (4 tests)\n\nEach test \u003C 20 lines. Use realistic data.\n```\n\n### 5. Ignoring Agent Uncertainty\n\n**Bad:**\n```\nAgent: \"I think the issue might be in the database connection, possibly related to connection pooling, though it could also be a timeout issue\"\nYou: \"Fix it\"\nAgent: [makes random changes]\n[Problem persists]\n```\n\n**Why bad:** Agent is guessing. Random changes waste time.\n\n**Fix:**\n```\nAgent: \"I think the issue might be...\"\nYou: \"You're uncertain. Let's diagnose first:\"\n  1. Add logging to connection pool\n  2. Check timeout configuration\n  3. Monitor connection count\n  4. Review recent DB changes\n\n[Gather data]\n[Identify root cause]\n[Make targeted fix]\n```\n\n## Trust Model Mismatch When Switching Tools\n\n**Problem:** Different AI coding tools have opposite default trust models. Switching between them without adjusting expectations causes surprises.\n\n| Tool | Default trust model | Isolation requires |\n|------|--------------------|--------------------|\n| Claude Code | Trust-first | Explicit permission boundaries |\n| OpenCode | Trust-first | Explicit sandbox config |\n| Cursor | Trust-first | No built-in sandboxing |\n| **Codex CLI** | **Sandbox-first** | **Opting out of restrictions** |\n\nCodex starts from a conservative sandbox posture. If a Codex task silently fails or\ncannot reach an API, check sandbox mode and approval settings before debugging the code.\n\n**Solution:**\n\nMatch your approval policy to the task, not to the tool's default:\n\n```bash\n# Codex: loosen when you need network or cross-dir writes\ncodex --sandbox danger-full-access \"deploy to staging\"\n\n# Claude Code \u002F OpenCode: tighten when running unreviewed tasks\n# (use scoped \u002Fplan mode or restrict tool permissions in config)\n```\n\nWhen switching between tools in the same workflow, explicitly state the trust context in your prompt:\n```\n# Be explicit regardless of which tool you're using:\n\"Read-only: explain the auth flow without making changes.\"\n\"Full access needed: update the database migration and test it.\"\n```\n\n## Verification Checklist\n\nAfter any agent-generated code:\n\n- [ ] Run linter\u002Fformatter (verify code style)\n- [ ] Run type checker (verify types are correct)\n- [ ] Run tests (verify behavior is correct)\n- [ ] Check for new dependencies (verify they exist on npm)\n- [ ] Review diff (verify changes match request)\n- [ ] Test locally (verify it works in dev)\n- [ ] Check logs (verify no silent errors)\n- [ ] Review config files (verify .env and .env.example match)\n- [ ] Check bundle size (verify no bloat)\n- [ ] Review security (verify no exposed secrets or vulnerabilities)\n\nIf any check fails: don't merge. Fix issues first.\n\nAI agents are powerful but unreliable. Build guardrails. Verify everything. Design for failure.\n","# AI Agent Gotchas\n\n> AI agents are powerful but predictably unreliable. Know their failure modes.\n\n## The Problem\n\nAI coding agents fail in consistent, predictable ways. They fabricate npm packages that don't exist. They catch errors and continue silently. They add features you never asked for. They lose context mid-session and forget what they were doing.\n\nThese aren't bugs—they're fundamental characteristics of LLM-based agents. You can't fix them, but you can work around them.\n\nThe insight: AI agents are reliable tools with unreliable execution. Build guardrails, verify outputs, and design workflows that assume failure.\n\n## The Pattern\n\n### 1. Atomic Edits for Multi-File Changes\n\n**Problem:** AI tools like Edit or Write run individually. If you make 5 file changes, there are 5 separate tool calls. Between tool calls, hooks can run, other sessions can interfere, or the agent can lose context.\n\n**Example failure:**\n```\nAgent: \"I'll update 3 files for the auth feature\"\n[Edit file1.ts] ✓\n[PostToolUse hook runs, reformats file1.ts]\n[Edit file2.ts] ✓\n[Another session force-pushes, rebases branch]\n[Edit file3.ts] ✗ Fails, branch state changed\n\nResult: Partial implementation, inconsistent state\n```\n\n**Solution: Single-transaction pattern**\n\nUse a shell script to make all changes atomically:\n\n```bash\npython3 \u003C\u003C 'EOF'\nimport json\n\n# Read all files\nwith open('file1.ts', 'r') as f:\n    file1 = f.read()\nwith open('file2.ts', 'r') as f:\n    file2 = f.read()\nwith open('file3.ts', 'r') as f:\n    file3 = f.read()\n\n# Make all changes\nfile1 = file1.replace('old1', 'new1')\nfile2 = file2.replace('old2', 'new2')\nfile3 = file3.replace('old3', 'new3')\n\n# Write all files\nwith open('file1.ts', 'w') as f:\n    f.write(file1)\nwith open('file2.ts', 'w') as f:\n    f.write(file2)\nwith open('file3.ts', 'w') as f:\n    f.write(file3)\nEOF\n\n# Atomic commit\ngit add file1.ts file2.ts file3.ts\ngit commit -m \"feat: implement auth feature\"\n```\n\n**Why this works:**\n- All file changes happen in one tool call (Bash)\n- Hooks run once at the end, not between edits\n- Other sessions can't interfere mid-edit\n- Agent can't lose context between files\n\n**When to use:**\n- Multi-file refactors (renaming, moving functions)\n- Feature implementation spanning multiple modules\n- Migration scripts (updating all files to new pattern)\n- Any change where partial completion is invalid\n\n### 2. Hook Interference\n\n**Problem:** PostToolUse hooks (Prettier, ESLint --fix, formatters) can revert agent changes.\n\n**Example failure:**\n```typescript\n\u002F\u002F Agent edits file to add function\nexport function newFeature() {\n  return \"value\"\n}\n\n\u002F\u002F PostToolUse hook runs Prettier\n\u002F\u002F Prettier removes \"unused\" import the function depends on\nimport { dependency } from '.\u002Flib';  \u002F\u002F REMOVED by hook\nexport function newFeature() {\n  return \"value\"  \u002F\u002F Now broken, missing dependency\n}\n```\n\n**Solution: Disable hooks for multi-step changes**\n\n```bash\n# Disable hooks temporarily\nexport SKIP_HOOKS=1\n\n# Make changes\n# ... agent edits files ...\n\n# Re-enable and run manually\nunset SKIP_HOOKS\nnpm run format\nnpm run lint:fix\ngit add .\ngit commit -m \"feat: add feature\"\n```\n\n**Or: Verify after each change**\n\n```bash\n# After agent edits\ngit diff  # Verify change is what you expect\nnpm run format  # Run formatters manually\ngit diff  # Verify formatters didn't break anything\ngit add .\ngit commit -m \"feat: add feature\"\n```\n\n**Where hooks interfere:**\n- Prettier removing \"unused\" code that's about to be used\n- ESLint auto-fixing away intentional patterns\n- TypeScript auto-imports conflicting with manual imports\n- Git hooks rejecting commits mid-workflow\n\n### 3. Session Interference\n\n**Problem:** Multiple AI sessions working on the same repository switch branches, force-push, or close PRs between each other's tool calls.\n\n**Example failure:**\n```\nSession A (Terminal 1):\n  [List files in feature\u002Fauth] ✓\n  [Read auth.ts] ✓\n\nSession B (Terminal 2):\n  git checkout main\n  git branch -D feature\u002Fauth\n  git push origin :feature\u002Fauth\n\nSession A (Terminal 1):\n  [Edit auth.ts] ✗ Error: branch 'feature\u002Fauth' not found\n```\n\n**Solution: Use worktrees for isolation**\n\n```bash\n# Session A\ngit worktree add ~\u002F.claude\u002Fworktrees\u002Fsession-a feature\u002Fauth\ncd ~\u002F.claude\u002Fworktrees\u002Fsession-a\n# Work here, fully isolated\n\n# Session B\ngit worktree add ~\u002F.claude\u002Fworktrees\u002Fsession-b feature\u002Fpayments\ncd ~\u002F.claude\u002Fworktrees\u002Fsession-b\n# Work here, can't interfere with Session A\n```\n\nSee [git-worktrees.md](git-worktrees.md) for full pattern.\n\n**Worktree isolation prevents:**\n- Branch switching mid-task\n- Force-push overwrites\n- PR closures breaking other sessions\n- Merge conflicts from simultaneous edits\n\n### 4. Context Window Overflow\n\n**Problem:** Long AI sessions accumulate context (files read, commands run, conversation history). After 100K+ tokens, early context is lost. Agent forgets project structure, coding standards, or what it was doing.\n\n**Example failure:**\n```\nEarly in session:\n  You: \"Use functional components, no classes\"\n  Agent: \"Got it, functional components only\"\n\n50 files later:\n  Agent: \"I'll create a class component for this feature\"\n  You: \"I said no classes!\"\n  Agent: \"Sorry, I don't see that instruction in our conversation\"\n```\n\n**Solution: Proactive context save**\n\nAt ~70% context usage (~140K tokens), save state:\n\n```bash\n# Save current progress\ncat > .claude\u002Fin-progress.md \u003C\u003C EOF\n# Auth Feature Implementation\n\n## Completed\n- [x] User model with email\u002Fpassword\n- [x] JWT generation utility\n- [x] Login endpoint\n\n## In Progress\n- [ ] Password reset flow\n- [ ] Email verification\n\n## Coding Standards\n- Functional components only\n- Functions \u003C 50 lines\n- Zod for validation (pattern: @lib\u002Fvalidators\u002Fuser.ts)\n\n## Next Steps\n1. Implement password reset token generation\n2. Add email sending service\n3. Create reset verification endpoint\nEOF\n\n# Compress context\n\u002Fcompact\n\n# Resume with loaded context\ncat .claude\u002Fin-progress.md\n# Continue work with fresh context window\n```\n\n**Automated context monitoring:**\n```bash\n# Add to shell prompt\nfunction context_usage() {\n  # Estimate based on conversation length\n  if [ -f .claude\u002Fcontext-estimate ]; then\n    cat .claude\u002Fcontext-estimate\n  fi\n}\n\nPS1='[$(context_usage)] $ '\n```\n\n### 5. Fabricated Metrics\n\n**Problem:** AI agents invent statistics, npm download counts, GitHub stars, or performance numbers when they don't have real data.\n\n**Example fabrication:**\n```markdown\n## Our Library\n\n- 100K+ npm downloads\u002Fmonth ?\n- 5K+ GitHub stars ⭐\n- 95% test coverage ✅\n- Used by companies like Google, Netflix, Uber\n\n(All numbers made up by AI)\n```\n\n**Real data:**\n- 47 npm downloads\u002Fmonth\n- 12 GitHub stars\n- 60% test coverage\n- No known enterprise users\n\n**Solution: Use dynamic badges with real data**\n\n```markdown\n## Our Library\n\n![npm downloads](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fdm\u002F@scope\u002Fpackage)\n![GitHub stars](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fuser\u002Frepo)\n![coverage](https:\u002F\u002Fimg.shields.io\u002Fcodecov\u002Fc\u002Fgithub\u002Fuser\u002Frepo)\n\n\u003C!-- Badges auto-update with real data -->\n```\n\n**Or: Fetch real metrics**\n\n```bash\n# Get npm downloads\nnpm_downloads=$(curl -s https:\u002F\u002Fapi.npmjs.org\u002Fdownloads\u002Fpoint\u002Flast-month\u002F@scope\u002Fpackage | jq '.downloads')\n\n# Get GitHub stars\ngh_stars=$(gh api repos\u002Fuser\u002Frepo --jq '.stargazers_count')\n\n# Update README with real data\nsed -i \"s\u002FDOWNLOADS_PLACEHOLDER\u002F$npm_downloads\u002Fg\" README.md\nsed -i \"s\u002FSTARS_PLACEHOLDER\u002F$gh_stars\u002Fg\" README.md\n```\n\n**Never trust agent-provided:**\n- Download counts, star counts, popularity metrics\n- Performance benchmarks (unless you ran them)\n- User testimonials or case studies\n- \"Industry standard\" claims\n\n**Always verify:**\n- npm API for download counts\n- GitHub API for stars\u002Fforks\n- Your own analytics for user counts\n- Actual benchmarks for performance\n\n### 6. Dependency Hallucination\n\n**Problem:** AI suggests packages that don't exist, outdated APIs, or deprecated libraries.\n\n**Example hallucination:**\n```typescript\n\u002F\u002F Agent suggestion\nimport { validateEmail } from '@utils\u002Femail-validator';\nimport { formatDate } from 'date-fns\u002Fformat';\nimport { parseJWT } from 'jwt-helper';\n\n\u002F\u002F Reality\n\u002F\u002F @utils\u002Femail-validator - doesn't exist\n\u002F\u002F date-fns\u002Fformat - wrong import path (should be 'date-fns')\n\u002F\u002F jwt-helper - package doesn't exist (maybe meant 'jsonwebtoken'?)\n```\n\n**Solution: Verify every new dependency**\n\n```bash\n# Before installing agent-suggested package\nnpm info \u003Cpackage-name>\n\n# Check if it exists, last publish date, version\n# If \"ERR! 404 Not Found\": package doesn't exist\n\n# Check actual API\nnpm info \u003Cpackage-name> exports\n# Or read the package README\n```\n\n**Red flags:**\n- Package name too generic (`email-validator`, `jwt-helper`)\n- No npm downloads\u002Fweek listed\n- Last publish > 2 years ago\n- No GitHub link or documentation\n\n**Safer approach:**\n```\nYou: \"I need to validate emails\"\nAgent: \"Use @utils\u002Femail-validator\"\nYou: \"Does this package exist? Check npm API first\"\nAgent: [checks] \"Package doesn't exist. Use 'validator' instead (2M downloads\u002Fweek)\"\n```\n\n### 7. Over-Engineering\n\n**Problem:** AI agents add features you didn't ask for: caching, logging, metrics, retry logic, feature flags, etc.\n\n**Example over-engineering:**\n```typescript\n\u002F\u002F You asked for: \"Add a function to get user by ID\"\n\n\u002F\u002F Agent delivers:\nasync function getUser(\n  id: string,\n  options: {\n    cache?: boolean;\n    cacheTTL?: number;\n    retry?: number;\n    timeout?: number;\n    includeDeleted?: boolean;\n    includeMetadata?: boolean;\n  } = {}\n): Promise\u003CUser> {\n  const cacheKey = `user:${id}`;\n\n  if (options.cache) {\n    const cached = await redis.get(cacheKey);\n    if (cached) {\n      logger.info('Cache hit', { userId: id });\n      return JSON.parse(cached);\n    }\n  }\n\n  let attempts = 0;\n  while (attempts \u003C (options.retry || 3)) {\n    try {\n      const user = await db.users.findById(id, {\n        includeDeleted: options.includeDeleted,\n        timeout: options.timeout || 5000\n      });\n\n      if (options.cache) {\n        await redis.set(cacheKey, JSON.stringify(user), 'EX', options.cacheTTL || 300);\n      }\n\n      logger.info('User fetched', { userId: id, attempts });\n      metrics.increment('user.fetch.success');\n\n      return user;\n    } catch (err) {\n      attempts++;\n      logger.error('User fetch failed', { userId: id, attempt: attempts, error: err });\n      metrics.increment('user.fetch.error');\n\n      if (attempts >= (options.retry || 3)) {\n        throw err;\n      }\n    }\n  }\n}\n\n\u002F\u002F You needed:\nasync function getUser(id: string): Promise\u003CUser> {\n  return db.users.findById(id);\n}\n```\n\n**Solution: Constrain scope explicitly**\n\n```\nAdd a function to get user by ID.\n\nRequirements:\n- Input: user ID (string)\n- Output: User object or throw NotFoundError\n- Implementation: Call db.users.findById()\n- NO caching, NO retry logic, NO logging, NO metrics\n- \u003C 10 lines\n\nExample:\nasync function getUser(id: string): Promise\u003CUser> {\n  const user = await db.users.findById(id);\n  if (!user) throw new NotFoundError('User not found');\n  return user;\n}\n```\n\n**Red flags for over-engineering:**\n- Function is 3x longer than expected\n- Added dependencies you didn't ask for\n- Options object with 5+ parameters\n- Feature flags for simple behavior\n- Caching\u002Fretry\u002Fcircuit-breaker for non-critical path\n\n### 8. Silent Failures\n\n**Problem:** AI agents catch errors and continue silently, hiding failures.\n\n**Example silent failure:**\n```typescript\nasync function processOrders(orders: Order[]) {\n  for (const order of orders) {\n    try {\n      await processOrder(order);\n    } catch (err) {\n      \u002F\u002F Agent added this silently\n      console.log('Failed to process order', err);\n      \u002F\u002F Continues to next order, no error thrown\n    }\n  }\n  return { success: true };  \u002F\u002F Lies!\n}\n\n\u002F\u002F Result: Some orders failed, but caller thinks all succeeded\n```\n\n**Solution: Explicit error handling strategy**\n\n```\nImplement processOrders(orders):\n- Process each order\n- On error: collect failed orders, don't stop processing\n- Return: { processed: Order[], failed: { order: Order, error: string }[] }\n- Let caller decide how to handle failures\n\nDO NOT catch and ignore errors silently.\n```\n\n**Better implementation:**\n```typescript\nasync function processOrders(orders: Order[]) {\n  const processed: Order[] = [];\n  const failed: { order: Order; error: string }[] = [];\n\n  for (const order of orders) {\n    try {\n      await processOrder(order);\n      processed.push(order);\n    } catch (err) {\n      failed.push({ order, error: err.message });\n    }\n  }\n\n  return { processed, failed };\n}\n```\n\n**Watch for:**\n- Try\u002Fcatch with only console.log\n- Errors caught but not re-thrown or returned\n- Success response when partial failure occurred\n- Missing error details in response\n\n### 9. Test Data Pollution\n\n**Problem:** AI-generated tests use unrealistic data that passes tests but fails in production.\n\n**Example bad test data:**\n```typescript\nit('creates user', async () => {\n  const user = await createUser({\n    email: 'test@test.com',\n    name: 'Test User',\n    age: 99\n  });\n\n  expect(user.id).toBeDefined();\n});\n\n\u002F\u002F Production failure:\n\u002F\u002F Real user \"María José García-López\" with email \"maria.jose@empresa.com\"\n\u002F\u002F Name validation rejects special characters!\n```\n\n**Solution: Realistic test data**\n\n```typescript\nit('creates user with international characters', async () => {\n  const user = await createUser({\n    email: 'maria.jose@empresa.com',\n    name: 'María José García-López',\n    age: 34\n  });\n\n  expect(user.id).toBeDefined();\n  expect(user.name).toBe('María José García-López');\n});\n```\n\n**Require realistic test data:**\n```\nGenerate tests for createUser.\n\nTest data requirements:\n- Real names (not \"Test User\", \"John Doe\", \"foo bar\")\n- Real email domains (not test.com, example.com)\n- International characters (María, 北京, Müller)\n- Edge cases (very long names, special characters, numbers)\n\nExamples of good test data:\n- \"Sarah Chen\", \"sarah.chen@company.com\"\n- \"José García\", \"jose.garcia@startup.io\"\n- \"李明\", \"liming@tech.cn\"\n```\n\n### 10. Configuration Drift\n\n**Problem:** Agent creates `.env.example` but doesn't update actual `.env`, or vice versa.\n\n**Example drift:**\n```bash\n# .env.example (what agent updated)\nDATABASE_URL=postgresql:\u002F\u002Flocalhost\u002Fmyapp\nREDIS_URL=redis:\u002F\u002Flocalhost:6379\nJWT_SECRET=your-secret-here\nNEW_FEATURE_FLAG=true  # Agent added this\n\n# .env (what's actually used)\nDATABASE_URL=postgresql:\u002F\u002Flocalhost\u002Fmyapp\nREDIS_URL=redis:\u002F\u002Flocalhost:6379\nJWT_SECRET=prod-secret\n# NEW_FEATURE_FLAG missing! Feature doesn't work.\n```\n\n**Solution: Sync config files**\n\n```\nAdd NEW_FEATURE_FLAG to environment config.\n\nUpdate BOTH files:\n1. .env.example (with placeholder value)\n2. .env (with actual value or prompt me for it)\n\nAfter updating, verify they have the same keys:\n```bash\ndiff \u003C(grep '^[A-Z]' .env | cut -d= -f1 | sort) \u003C(grep '^[A-Z]' .env.example | cut -d= -f1 | sort)\n```\n\nIf diff shows missing keys, update both files.\n```\n\n**Automated sync check:**\n```bash\n# add to CI\nnpm run config-check\n\n# package.json\n{\n  \"scripts\": {\n    \"config-check\": \"node scripts\u002Fcheck-env-sync.js\"\n  }\n}\n\n\u002F\u002F scripts\u002Fcheck-env-sync.js\nconst fs = require('fs');\n\nconst env = fs.readFileSync('.env', 'utf8');\nconst example = fs.readFileSync('.env.example', 'utf8');\n\nconst envKeys = env.match(\u002F^[A-Z_]+=\u002Fgm)?.map(k => k.slice(0, -1)) || [];\nconst exampleKeys = example.match(\u002F^[A-Z_]+=\u002Fgm)?.map(k => k.slice(0, -1)) || [];\n\nconst missing = exampleKeys.filter(k => !envKeys.includes(k));\nif (missing.length > 0) {\n  console.error('Missing in .env:', missing);\n  process.exit(1);\n}\n```\n\n## Anti-Patterns\n\n### 1. Trusting Agent Memory\n\n**Bad:**\n```\nSession start:\n  You: \"Use TypeScript strict mode and Zod validation\"\n  Agent: \"Got it\"\n\n2 hours later:\n  Agent: *generates code with implicit any and no validation*\n  You: \"I told you to use strict mode!\"\n  Agent: \"I don't recall that instruction\"\n```\n\n**Why bad:** Context window is limited. Early instructions are forgotten.\n\n**Fix:**\n```\nCreate .claude\u002Fstandards.md:\n\n# Coding Standards\n- TypeScript strict mode (no implicit any)\n- Zod for all input validation\n- Functions \u003C 50 lines\n- No classes, use functional components\n\nReference this file at start of each session:\n\"Follow the standards in .claude\u002Fstandards.md\"\n```\n\n### 2. No Verification After Agent Changes\n\n**Bad:**\n```\nAgent: \"I've updated the database schema\"\nYou: \"Great, thanks!\"\n[deploys to production]\n[production crashes - migration broke]\n```\n\n**Why bad:** Agent might have made incorrect changes, broken migrations, or missed edge cases.\n\n**Fix:**\n```\nAgent: \"I've updated the database schema\"\nYou: \"Show me the diff\"\n[Review changes]\nYou: \"Run the migration on a test database first\"\n[Verify it works]\nYou: \"Run rollback test\"\n[Verify rollback works]\nYou: \"Now deploy to production\"\n```\n\n### 3. Accepting First Solution\n\n**Bad:**\n```\nYou: \"How do I cache API responses?\"\nAgent: \"Use an in-memory Map\"\nYou: \"Okay\" [implements in-memory cache]\n[Doesn't scale, memory leak in production]\n```\n\n**Why bad:** Agent gives first solution that pops up, not best solution.\n\n**Fix:**\n```\nYou: \"How do I cache API responses? List 3 options with tradeoffs\"\nAgent:\n  1. In-memory Map (fast, doesn't scale across servers, memory leak risk)\n  2. Redis (scales, adds latency, requires infrastructure)\n  3. CDN caching (fastest, limited control, only for public data)\n\nYou: \"We have Redis already. Use option 2\"\n```\n\n### 4. Not Constraining Output Size\n\n**Bad:**\n```\nYou: \"Generate tests for UserService\"\nAgent: [generates 500 tests, 3000 lines, covers every possible permutation]\n```\n\n**Why bad:** Too many tests = slow CI, hard to maintain, diminishing returns.\n\n**Fix:**\n```\nYou: \"Generate 10 critical tests for UserService\"\n- Happy path (1 test)\n- Validation errors (3 tests)\n- Permission errors (2 tests)\n- Edge cases (4 tests)\n\nEach test \u003C 20 lines. Use realistic data.\n```\n\n### 5. Ignoring Agent Uncertainty\n\n**Bad:**\n```\nAgent: \"I think the issue might be in the database connection, possibly related to connection pooling, though it could also be a timeout issue\"\nYou: \"Fix it\"\nAgent: [makes random changes]\n[Problem persists]\n```\n\n**Why bad:** Agent is guessing. Random changes waste time.\n\n**Fix:**\n```\nAgent: \"I think the issue might be...\"\nYou: \"You're uncertain. Let's diagnose first:\"\n  1. Add logging to connection pool\n  2. Check timeout configuration\n  3. Monitor connection count\n  4. Review recent DB changes\n\n[Gather data]\n[Identify root cause]\n[Make targeted fix]\n```\n\n## Trust Model Mismatch When Switching Tools\n\n**Problem:** Different AI coding tools have opposite default trust models. Switching between them without adjusting expectations causes surprises.\n\n| Tool | Default trust model | Isolation requires |\n|------|--------------------|--------------------|\n| Claude Code | Trust-first | Explicit permission boundaries |\n| OpenCode | Trust-first | Explicit sandbox config |\n| Cursor | Trust-first | No built-in sandboxing |\n| **Codex CLI** | **Sandbox-first** | **Opting out of restrictions** |\n\nCodex starts from a conservative sandbox posture. If a Codex task silently fails or\ncannot reach an API, check sandbox mode and approval settings before debugging the code.\n\n**Solution:**\n\nMatch your approval policy to the task, not to the tool's default:\n\n```bash\n# Codex: loosen when you need network or cross-dir writes\ncodex --sandbox danger-full-access \"deploy to staging\"\n\n# Claude Code \u002F OpenCode: tighten when running unreviewed tasks\n# (use scoped \u002Fplan mode or restrict tool permissions in config)\n```\n\nWhen switching between tools in the same workflow, explicitly state the trust context in your prompt:\n```\n# Be explicit regardless of which tool you're using:\n\"Read-only: explain the auth flow without making changes.\"\n\"Full access needed: update the database migration and test it.\"\n```\n\n## Verification Checklist\n\nAfter any agent-generated code:\n\n- [ ] Run linter\u002Fformatter (verify code style)\n- [ ] Run type checker (verify types are correct)\n- [ ] Run tests (verify behavior is correct)\n- [ ] Check for new dependencies (verify they exist on npm)\n- [ ] Review diff (verify changes match request)\n- [ ] Test locally (verify it works in dev)\n- [ ] Check logs (verify no silent errors)\n- [ ] Review config files (verify .env and .env.example match)\n- [ ] Check bundle size (verify no bloat)\n- [ ] Review security (verify no exposed secrets or vulnerabilities)\n\nIf any check fails: don't merge. Fix issues first.\n\nAI agents are powerful but unreliable. Build guardrails. Verify everything. Design for failure.\n",{"name":5,"description":7},"main","4081c4af3adf7955205b04e1f4a7eb3cebaea9f6","packages\u002Fcatalog\u002Fcatalog\u002Fskills\u002Fagent-gotchas","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev","https:\u002F\u002Flucassantana.tech","Senior engineer. AI agent tooling and evals on Node\u002FTS backends. Brazil, UTC-3.","2026-11-14 10:13:13",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add LucasSantana-Dev\u002Fforgekit --skill agent-gotchas",{"tool":52,"command":53},"bunx","bunx skills add LucasSantana-Dev\u002Fforgekit --skill agent-gotchas",{"tool":55,"command":56},"pnpm","pnpm dlx skills add LucasSantana-Dev\u002Fforgekit --skill agent-gotchas","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcatalog\u002Fcatalog\u002Fskills\u002Fagent-gotchas\u002FSKILL.md",true,[60,66,72,76,80],{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"manifest.json","REFERENCE","参考文档",955,"https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcatalog\u002Fcatalog\u002Fskills\u002Fagent-gotchas\u002Fmanifest.json",{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"scripts\u002Fdiscover_and_rank.ps1","SCRIPT","脚本",4670,"https:\u002F\u002Fgithub.com\u002Fagency-black\u002FSkills\u002Fblob\u002Fmain\u002Fmicrosoft-foundry\u002Fmodels\u002Fdeploy-model\u002Fcapacity\u002Fscripts\u002Fdiscover_and_rank.ps1",{"path":73,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":74,"sourceHtmlUrl":75},"scripts\u002Fdiscover_and_rank.sh",4641,"https:\u002F\u002Fgithub.com\u002Fagency-black\u002FSkills\u002Fblob\u002Fmain\u002Fmicrosoft-foundry\u002Fmodels\u002Fdeploy-model\u002Fcapacity\u002Fscripts\u002Fdiscover_and_rank.sh",{"path":77,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":78,"sourceHtmlUrl":79},"scripts\u002Fquery_capacity.ps1",3030,"https:\u002F\u002Fgithub.com\u002Fagency-black\u002FSkills\u002Fblob\u002Fmain\u002Fmicrosoft-foundry\u002Fmodels\u002Fdeploy-model\u002Fcapacity\u002Fscripts\u002Fquery_capacity.ps1",{"path":81,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":82,"sourceHtmlUrl":83},"scripts\u002Fquery_capacity.sh",2942,"https:\u002F\u002Fgithub.com\u002Fagency-black\u002FSkills\u002Fblob\u002Fmain\u002Fmicrosoft-foundry\u002Fmodels\u002Fdeploy-model\u002Fcapacity\u002Fscripts\u002Fquery_capacity.sh",[85,111,138,160,169,187],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":33},"01M6WR9SQGQ5WDEJY9HH3T93E8","token-audit","Audit historical Claude Code token usage from JSONL session files — shows total spend, cache hit rates, top costly sessions, weekly trends, and where tokens are going. Run after heavy sessions or weekly to measure optimization impact. Answers how many tokens a session used, how expensive was that session, session cost, and token usage report.","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcatalog\u002Fcatalog\u002Fskills\u002Fadt-token-audit\u002FSKILL.md",[],[92,93,94,27,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110],"audit","token","token audit","rate","weekly","top","usage","jsonl","usage report","impact","tokens","files","cost","how","Optimization","cache","code","run","sessions",{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":33},"01M6WR919T3NGWMZ5R5XKWX9KN","smart-model-route","Auto-classify prompt complexity via Haiku (with heuristic fallback) and inject model routing hints for Agent tool calls. Wired as a UserPromptSubmit hook — fires on every prompt, routes low tasks to Haiku, standard to Sonnet, complex to Sonnet with thorough reasoning, and critical (security\u002Farch\u002Fmigrations) to Opus. Handles model selection, for example choose model by task complexity.","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcatalog\u002Fcatalog\u002Fskills\u002Fadt-smart-model-route\u002FSKILL.md",[],[118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137],"smart model route","route","model route","model","security","model selection","tasks","critical","arch","classify","selection","fallback","complexity","auto","opus","haiku","choose","hook","agent tool","sonnet",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":33},"01M6WR8TMGS9G79DFTX0K1ZA8T","smart-commands","Decision guide for when to proactively use Claude Code slash commands — \u002Fthink, \u002Fmodel, \u002Fcompact, \u002Fclear. Use when choosing whether to invoke a command before or during a task, or when a complexity-classifier hook has flagged a task as high or critical. Pairs with the complexity-classifier UserPromptSubmit hook. Answers when to compact, should I switch models, and whether to use extended thinking. Use to pick the right \u002Fmodel command and switch model.","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcatalog\u002Fcatalog\u002Fskills\u002Fadt-smart-commands\u002FSKILL.md",[],[145,146,147,148,149,150,135,125,151,152,153,154,130,155,156,157,158,159,121,108],"smart commands","commands","when","as","use","for","compact","thinking","switch","classifier","invoke","guide","command","decision","pick",{"skillNo":161,"name":162,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":33},"01M6E0ZGQ78S4SE6X6RCN1PR9A","spec-ship","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fkit\u002Fspecs\u002Fskills\u002Fspec-ship\u002FSKILL.md",[],[166,167,168],"spec","ship","spec ship",{"skillNo":170,"name":171,"nameZh":6,"description":172,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":173,"categories":174,"keywords":175,"publishedAt":33},"01M6E0ZD27S87Z954JTHECWG34","spec-new","Create a committed per-feature spec under `docs\u002Fspecs\u002FYYYY-MM-DD-\u003Cslug>\u002F{spec,tasks}.md` with frontmatter (status, created, owner, pr, tags). Promotes an ephemeral `.claude\u002Fplans\u002F\u003Cname>.md` into a persistent, searchable artifact. Use when starting a feature that's larger than a one-shot PR.","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fkit\u002Fspecs\u002Fskills\u002Fspec-new\u002FSKILL.md",[],[176,166,177,149,178,179,124,180,181,182,183,184,185,186],"spec new","artifact","dd","create","pr","status","docs","feature","tags","name","plans",{"skillNo":188,"name":189,"nameZh":6,"description":190,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":191,"categories":192,"keywords":193,"publishedAt":33},"01M6E0Z9B5YE1G4NM05JPNVWMK","roadmap-refresh","Regenerate `docs\u002Froadmap.md` for a repo from all specs under `docs\u002Fspecs\u002F` + their frontmatter (status, tags, pr). Produces Now\u002FNext\u002FRecently-shipped sections. Run after creating \u002F shipping a spec, or at the start of a new session for orientation.","https:\u002F\u002Fgithub.com\u002FLucasSantana-Dev\u002Fforgekit\u002Fblob\u002Fmain\u002Fpackages\u002Fcore\u002Fkit\u002Fspecs\u002Fskills\u002Froadmap-refresh\u002FSKILL.md",[],[194,195,196,197,184,198,27,199,200,201,202,109,180,181,182,166],"roadmap refresh","roadmap","refresh","next","now","repo","new session","start","shipping"]