agentcore-cli
AGENTS.md301 starsChanged 3 months agoApache-2.0View on GitHub
CLI tool for Amazon Bedrock AgentCore. Manages agent infrastructure lifecycle. Note: CDK L3 constructs are in a separate package @aws/agentcore-cdk. These options are available on all commands: - create - Create new AgentCore project - add - Add resources (agent, memory, credential, evaluator, online-eval, gateway, gateway-target, policy-engine, policy, payment-manager, payment-connector, capacity-provider) - remove - Remove resources (agent, memory, credential, evaluator, online-eval, gateway, gateway-target, policy-engine, policy, payment-manager, payment-connector, capacity-provider, all) - deploy - Deploy infrastructure to AWS - status - Check…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository12 other files it gives its agents.
- examples/AgentCoreCliReviewer/AGENTS.mdAGENTS.md
- src/assets/agents/AGENTS.mdAGENTS.md
- src/assets/AGENTS.mdAGENTS.md
- src/cli/AGENTS.mdAGENTS.md
- src/cli/commands/AGENTS.mdAGENTS.md
- src/cli/templates/AGENTS.mdAGENTS.md
- src/cli/tui/AGENTS.mdAGENTS.md
- src/lib/AGENTS.mdAGENTS.md
- src/schema/AGENTS.mdAGENTS.md
- src/schema/llm-compacted/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- acr-reportSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
13 rules. About 0 are common, 3 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 62
Imported agents: Import from Bedrock Agents with agentcore add agent --type import
- Very specific: line 72
All resource types (agent, memory, credential, evaluator, online-eval, gateway, gateway-target, policy-engine, policy) are modeled as …
- Very specific: line 101
When users run agentcore create, we vend a CDK project at agentcore/cdk/ that:
- Distinctive: line 140
Never use inline imports. Imports must always go at the top of the file.
- Distinctive: line 148
Always look for existing types before creating a new type inline.
- Very specific: line 182
Add 'MyNewError' to the ErrorName enum in src/cli/telemetry/schemas/common-shapes.ts.
- Very specific: line 197
ARN regex patterns: must use arn:[^:]+: (not arn:aws:) to match any partition.
- Distinctive: line 203
Update these files in the CLI repo:
- Very specific: line 210
Update these files in the CDK repo (@aws/agentcore-cdk):
- Very specific: line 219
Add a new entry to PARTITION_CONFIGS in src/cli/aws/partition.ts with the region prefix, partition name, DNS suffix, and console domain.
- Very specific: line 221
Add tests for the new partition in src/cli/aws/__tests__/partition.test.ts.
- Very specific: line 222
Update src/assets/cdk/cdk.json — add the partition to @aws-cdk/core:target-partitions.
- Very specific: line 223
Run npm run test:update-snapshots to update asset snapshots.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AgentCore CLI
CLI tool for Amazon Bedrock AgentCore. Manages agent infrastructure lifecycle.
Package Structure
src/
├── index.ts # Library entry - exports ConfigIO, types
├── schema/ # Schema definitions with Zod validators
├── lib/ # Shared utilities (ConfigIO, packaging)
├── cli/ # CLI implementation
│ ├── primitives/ # Resource primitives (add/remove logic per resource type)
│ ├── commands/ # CLI commands (thin Commander registration)
│ ├── tui/ # Terminal UI (Ink/React)
│ ├── operations/ # Shared business logic (schema mapping, deploy, etc.)
│ ├── cdk/ # CDK toolkit wrapper for programmatic CDK operations
│ └── templates/ # Project templating
└── assets/ # Template assets vended to usersNote: CDK L3 constructs are in a separate package @aws/agentcore-cdk.
Global Options
These options are available on all commands:
-h, --help- Show help for any command--version- Print CLI version (root command only)
CLI Commands
create- Create new AgentCore projectadd- Add resources (agent, memory, credential, evaluator, online-eval, gateway, gateway-target, policy-engine, policy, payment-manager, payment-connector, capacity-provider)remove- Remove resources (agent, memory, credential, evaluator, online-eval, gateway, gateway-target, policy-engine, policy, payment-manager, payment-connector, capacity-provider, all)deploy- Deploy infrastructure to AWSstatus- Check deployment statusdev- Local development server (CodeZip: uvicorn with hot-reload; Container: Docker build + run with volume mount)invoke- Invoke agents (local or deployed)capacity-provider delete-session- Delete (deprovision) a live capacity provider session (data-plane)run eval- Run on-demand evaluation against agent sessionsevals history- View past eval run resultsfetch access- Fetch access info for a deployed gateway or agentimport- Import resources from a Bedrock AgentCore Starter Toolkit projectpause online-eval- Pause (disable) a deployed online eval configresume online-eval- Resume (enable) a paused online eval configlogs- Stream or search agent runtime logslogs evals- Stream or search online eval logstraces list- List recent traces for a deployed agenttraces get- Download a trace to a JSON filepackage- Package agent artifacts without deploying (zip for CodeZip, container image build for Container)validate- Validate configuration filesupdate- Check for CLI updateshelp- Display help information
Agent Types
- Template agents: Created from framework templates (Strands, LangChain_LangGraph, GoogleADK, OpenAIAgents)
- BYO agents: Bring your own code with
agentcore add agent --type byo - Imported agents: Import from Bedrock Agents with
agentcore add agent --type import
Build Types
- CodeZip: Python source is packaged into a zip artifact and deployed to AgentCore Runtime (default)
- Container: Agent is built as a Docker container image, deployed via ECR and CodeBuild. Requires a
Dockerfilein the agent's code directory. Supported container runtimes: Docker, Podman, Finch.
Primitives Architecture
All resource types (agent, memory, credential, evaluator, online-eval, gateway, gateway-target, policy-engine, policy)
are modeled as primitives -- self-contained classes in src/cli/primitives/ that own the full add/remove lifecycle
for their resource type. Resources support config-driven tagging via agentcore.json, with tags flowing through to
deployed CloudFormation resources.
Each primitive extends BasePrimitive and implements: add(), remove(), previewRemove(), getRemovable(),
registerCommands(), and addScreen().
Current primitives:
AgentPrimitive— agent creation (template + BYO), removal, credential resolution. Template agents: Strands, LangChain_LangGraph, GoogleADK, OpenAIAgents, VercelAIMemoryPrimitive— memory creation with strategies, removalCredentialPrimitive— credential creation, .env management, removalEvaluatorPrimitive— custom evaluator creation/removal with cross-reference validationOnlineEvalConfigPrimitive— online eval config creation/removalGatewayPrimitive— gateway creation/removalGatewayTargetPrimitive— gateway target creation/removal with code generationPolicyEnginePrimitive— Cedar policy engine creation/removalPolicyPrimitive— Cedar policy creation/removal within policy enginesPaymentManagerPrimitive— payment manager creation/removal with agent code wiringPaymentConnectorPrimitive— payment connector creation/removal with credential managementCapacityProviderPrimitive— capacity provider creation/removal (customer-managed EC2 compute pool for runtimes)
Singletons are created in registry.ts and wired into CLI commands via cli.ts. See src/cli/AGENTS.md for details on
adding new primitives.
Vended CDK Project
When users run agentcore create, we vend a CDK project at agentcore/cdk/ that:
- Imports
@aws/agentcore-cdkfor L3 constructs - Reads schema files and synthesizes CloudFormation
Library Exports
This package exports utilities for programmatic use:
ConfigIO- Read/write schema files- Schema types -
AgentEnvSpec,AgentCoreProjectSpec, etc. findConfigRoot()- Locate agentcore/ directory
Testing
Unit Tests
npm test # Run unit tests
npm run test:unit # Same as above
npm run test:integ # Run integration testsSnapshot Tests
Asset files in src/assets/ are protected by snapshot tests. When modifying templates:
npm run test:update-snapshots # Update snapshots after intentional changesSee docs/TESTING.md for details.
Related Package
@aws/agentcore-cdk- CDK constructs used by vended projects
Code Style
- Never use inline imports. Imports must always go at the top of the file.
- Wheverever there is a requirement to use something that returns a success result and an error message you must use this format
{ success: Boolean, error?:string}- Always look for existing types before creating a new type inline.
- Re-usable constants must be defined in a constants file in the closest sensible subdirectory.
Telemetry
New features must include telemetry instrumentation. See src/cli/telemetry/README.md for how to add metrics.
Error Types
Custom error types are encouraged — each distinct error class appears as its own category in telemetry, giving more
granular failure data. All errors live in src/lib/errors/types.ts.
To add a new error:
- Define a class in
src/lib/errors/types.tsextendingBaseErrorwith a defaulterrorSource:'user'— user-fixable (bad input, missing credentials, invalid config)'client'— our bug or unexpected local failure'service'— remote service issue (timeout, connection failure, server error)'unknown'— source cannot be determined
export class MyNewError extends BaseError {
constructor(message: string, options?: BaseErrorOptions) {
super(message, { defaultSource: 'user', ...options });
}
}Callers can override the source per throw site:
throw new MyNewError('not found', { errorSource: 'service', cause: originalErr });- Add
'MyNewError'to theErrorNameenum insrc/cli/telemetry/schemas/common-shapes.ts.
That's it. The telemetry client reads errorSource and name directly from BaseError instances — no classification
logic to update.
Multi-Partition Support (GovCloud, China)
The CLI supports multiple AWS partitions (commercial, GovCloud, China) through a central utility at
src/cli/aws/partition.ts. This module maps region prefixes to partition-specific values.
Rules
- Never hardcode
arn:aws:in ARN construction. UsearnPrefix(region)fromsrc/cli/aws/partition.ts. - Never hardcode
amazonaws.comin endpoint URLs. UseserviceEndpoint(service, region)ordnsSuffix(region). - Never hardcode
console.aws.amazon.comin console URLs. UseconsoleDomain(region). - ARN regex patterns must use
arn:[^:]+:(notarn:aws:) to match any partition. - Static JSON assets (e.g., IAM policies in
src/assets/) cannot use TypeScript utilities — usearn:*:as the partition wildcard since IAM evaluates it across all partitions.
Adding a New Region
Update these files in the CLI repo:
src/schema/schemas/aws-targets.ts— add toAgentCoreRegionSchemaenumsrc/schema/llm-compacted/aws-targets.ts— add toAgentCoreRegiontype unionsrc/schema/schemas/__tests__/aws-targets.test.ts— add tovalidRegionsarraysrc/cli/operations/agent/import/constants.ts— add toBEDROCK_REGIONS(if applicable to Bedrock Agent import)
Update these files in the CDK repo (@aws/agentcore-cdk):
src/schema/schemas/aws-targets.ts— add toAgentCoreRegionSchemaenumsrc/schema/llm-compacted/aws-targets.ts— add toAgentCoreRegiontype union
Then run npm run test:update-snapshots in the CLI repo if any asset files changed.
Adding a New Partition
- Add a new entry to
PARTITION_CONFIGSinsrc/cli/aws/partition.tswith the region prefix, partition name, DNS suffix, and console domain. - Add tests for the new partition in
src/cli/aws/__tests__/partition.test.ts. - Update
src/assets/cdk/cdk.json— add the partition to@aws-cdk/core:target-partitions. - Run
npm run test:update-snapshotsto update asset snapshots.
TUI Harness
See docs/tui-harness.md for the full TUI harness usage guide (MCP tools, screen markers, examples, and error
recovery).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

