How do AI coding agents like Claude Code decide which libraries and APIs to install? Agents, guardrails, and what to automate
Claude Code and Codex let the model choose libraries and APIs. What the docs say steers that choice, which guardrails you can automate, and what a person should own.
When Claude Code runs npm install on its own, you are watching an agent act, not report. That makes this question a good test of the idea behind this site. If one agent is picking the dependencies, which parts of the surrounding work can other agents handle, and which parts still need someone to say yes?
The choice belongs to the model
Start with what the vendors say. Anthropic's "How Claude Code works" page describes a loop of gathering context, taking action, and verifying results, chained over dozens of steps. It says Claude chooses which tools to use based on the prompt and what it learns along the way, and that this is the model doing the reasoning. Claude Code can run anything you could run in a terminal, package managers included, and its web tools search the web and fetch documentation.
OpenAI's Codex documentation adds that Codex reads AGENTS.md before working and uses a cached search index by default, with live search as an option.
The missing piece is the selection logic. No official Anthropic or OpenAI page explains how these agents rank one library or API against another. Anyone automating around them is automating around a judgment call they cannot inspect.
Guardrails a team can automate
Because the choice is opaque, the controls sit around it. Most can be set once and left to run.
Instruction files are the first layer. Claude Code reads CLAUDE.md (or AGENTS.md) every session, and Codex reads AGENTS.md. OpenAI's example file shows the kind of rule that works: prefer pnpm when installing dependencies, and ask before adding new production dependencies. Write your approved libraries there and the agent sees them before it searches.
Permission rules are the second. Claude Code lets you allow specific commands in .claude/settings.json so trusted ones run without a prompt, and its Auto mode has a classifier block risky actions instead of asking. A team can allow npm test freely and leave npm install gated.
Pinned versions are the third, with a limit worth knowing. Claude Code installs plugin dependencies at exactly the versions in a lockfile, with lifecycle scripts disabled. That rule covers plugins, not the libraries Claude picks for your project, so your own lockfile and CI still do that job.
What should stay with a person
Approving new production dependencies. OpenAI's own example asks the agent to confirm first, and we agree. A model that searched the web for "best PDF library" has no stake in your license policy or your bundle size.
Choosing MCP servers. The Model Context Protocol is an open standard that lets apps like Claude and ChatGPT connect to tools and data, and coding agents use it heavily.

The "What is the Model Context Protocol (MCP)?" page on modelcontextprotocol.io, captured November 21, 2026.
The official MCP Registry is in preview, stores metadata rather than code, and leaves security scanning to package registries and downstream aggregators. Its own docs say it is not meant to be read directly by host applications. Nothing there vets a server for you.

The "MCP Registry" about page, captured November 21, 2026.
Anything touching remote systems. Claude Code's checkpoints undo file edits, but its docs say actions on databases, APIs, and deployments cannot be checkpointed.
The vendor side: automating the "are we being picked?" loop
If you build the library or API being chosen, the work flips. You cannot see inside the agent's decision, but you can measure its output repeatedly, and that is automatable.
Promptwatch tracks what Codex, Claude Code, and OpenCode recommend, in the same project as ChatGPT, Gemini, and Perplexity. Once those monitors run, the rest of the loop can run through agents too. The hosted Promptwatch MCP server has 110+ read and write tools and works inside Claude Code, Codex, and Cursor (one-click install in Cursor), so a developer-relations engineer can ask the same coding agent "which prompts did we lose to a competitor this week?" without opening a dashboard. Agent Chat runs multi-step analyses on the live data. The Action Board's Discovery agent investigates on a weekly schedule and suggests up to five evidence-backed actions per run.
The fixes are often documentation. On the Business plan, the Content Agent plans and writes against visibility gaps with a review inbox, and Content Refresh proposes diff-style updates to existing pages. Agent Analytics (from Professional) shows whether crawlers such as ClaudeBot, Claude-SearchBot, GPTBot, and Exa's ExaSearchBot reach those docs at all. Exa matters here because OpenCode searches the web through it.
What still needs your people: deciding which prompts represent real developer tasks, and approving the content before it ships.
Agentic tools for devtool teams, ranked
- Promptwatch: coding-agent tracking plus MCP, Agent Chat, Action Board, and Content Agent. Essential $95/mo, Business $579/mo for the Content Agent.
- AthenaHQ: Action Center and content optimization agent across 11 models, Starter $295/mo; coding agents are not named in its catalog entry.
- DispatchSEO: open-source SEO manager over MCP for Claude Code, Codex, and Cursor, shipping pull requests.
- SEOAgent: a free Skill inside your own coding agent, with a paid cloud Autopilot.
- Okara: a Coding Agent that opens GitHub pull requests for technical SEO fixes; nothing merges without approval.
- Encited: hosted MCP server for Claude Code, Cursor, ChatGPT, and Lovable.
Tools three to six mostly work through coding agents rather than watching them, and of the six, only Promptwatch lists Codex, Claude Code, and OpenCode as tracked engines. To see the MCP side working, book a Promptwatch demo and ask them to run a query from Claude Code.