Skip to content

Commit 9404690

Browse files
authored
Merge pull request #4 from damc-dev:feature/CLAUDEMD
docs: add CLAUDE.md for project guidance and commands
2 parents 14eee1f + 3c7dfdb commit 9404690

1 file changed

Lines changed: 117 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
```bash
8+
# Install dependencies
9+
uv sync
10+
11+
# Run agent locally (serves on port 8080)
12+
uv run python agent.py
13+
14+
# Test locally
15+
curl -X POST http://localhost:8080/invocations \
16+
-H "Content-Type: application/json" \
17+
-d '{"prompt": "Hello!"}'
18+
19+
# Deploy a specific agent to AWS
20+
uv run agentcore launch --agent <agent-name>
21+
22+
# Configure a new agent
23+
uv run agentcore configure --agent <new-agent-name>
24+
25+
# Build Docker image locally
26+
docker build -t bedrock-agentcore-agent .
27+
28+
# Monitor GitHub Actions deployments
29+
gh run list --workflow=deploy-agent.yml
30+
gh run watch # watch the latest run
31+
gh run view <run-id> # view details of a specific run
32+
gh run view <run-id> --log # view logs
33+
```
34+
35+
## Architecture
36+
37+
This project demonstrates **continuous deployment of AWS Bedrock AgentCore agents** — every push to `main` auto-deploys all configured agents via GitHub Actions.
38+
39+
### Core Components
40+
41+
**`agent.py`** — The agent entrypoint. Wraps a [Strands](https://strandsagents.com) `Agent` in a `BedrockAgentCoreApp`, exposing an `invoke` function decorated with `@app.entrypoint` that receives a `payload` dict and returns a response dict.
42+
43+
**`.bedrock_agentcore.yaml`** — Central config tracking AWS resources per agent: ECR repo, execution role ARNs, CodeBuild project, Bedrock agent IDs. This file is updated by `agentcore launch` and committed back.
44+
45+
**`.github/workflows/deploy-agent.yml`** — Two-stage pipeline:
46+
1. **Setup job**: Extracts agent names from `.bedrock_agentcore.yaml` using `yq`, outputs a JSON matrix
47+
2. **Deploy job**: Runs in parallel per agent, authenticates to AWS via OIDC (preferred) or access keys, then runs `agentcore launch`
48+
49+
### Adding a New Agent
50+
51+
1. Create a new Python file (e.g., `my_agent.py`) following the same `BedrockAgentCoreApp` pattern
52+
2. Run `uv run agentcore configure --agent my-agent` to register it in `.bedrock_agentcore.yaml`
53+
3. Push to `main` — the CI/CD pipeline auto-deploys all agents defined in `.bedrock_agentcore.yaml`
54+
55+
### Key Dependencies
56+
57+
- **bedrock-agentcore**: AWS SDK for deploying/running agents on Bedrock AgentCore
58+
- **strands-agents**: Agent framework (use `from strands import Agent`)
59+
- **bedrock-agentcore-starter-toolkit**: Provides the `agentcore` CLI (dev dependency)
60+
61+
### AWS Infrastructure
62+
63+
The deployment uses:
64+
- ECR for container images
65+
- CodeBuild for building/pushing images
66+
- Bedrock AgentCore runtime for serving
67+
- IAM OIDC for GitHub Actions authentication (configured in repo secrets as `AWS_ROLE_TO_ASSUME`)
68+
69+
## AWS CLI — Check Agent Config & Logs
70+
71+
Agent IDs and region are sourced from `.bedrock_agentcore.yaml`. Use `yq` to extract them:
72+
73+
```bash
74+
AGENT_NAME=$(yq '.default_agent' .bedrock_agentcore.yaml)
75+
AGENT_ID=$(yq ".agents.${AGENT_NAME}.bedrock_agentcore.agent_id" .bedrock_agentcore.yaml)
76+
REGION=$(yq ".agents.${AGENT_NAME}.aws.region" .bedrock_agentcore.yaml)
77+
```
78+
79+
### Check agent runtime configuration
80+
81+
```bash
82+
# Get agent status and full config
83+
aws bedrock-agentcore-control get-agent-runtime \
84+
--agent-runtime-id "$AGENT_ID" \
85+
--region "$REGION"
86+
87+
# List all agent runtimes in the account
88+
aws bedrock-agentcore-control list-agent-runtimes --region "$REGION"
89+
90+
# List endpoints (you'll need the endpoint name for log queries)
91+
aws bedrock-agentcore-control list-agent-runtime-endpoints \
92+
--agent-runtime-id "$AGENT_ID" \
93+
--region "$REGION"
94+
```
95+
96+
### Check logs (CloudWatch)
97+
98+
Log groups follow the pattern `/aws/bedrock-agentcore/runtimes/<agent-id>-<endpoint-name>`. The endpoint name is typically `DEFAULT`.
99+
100+
```bash
101+
# Discover the log group(s) for this agent
102+
aws logs describe-log-groups \
103+
--log-group-name-prefix "/aws/bedrock-agentcore/runtimes/${AGENT_ID}" \
104+
--region "$REGION"
105+
106+
# Live-tail logs (AWS CLI v2)
107+
aws logs tail \
108+
"/aws/bedrock-agentcore/runtimes/${AGENT_ID}-DEFAULT" \
109+
--region "$REGION" \
110+
--follow
111+
112+
# Filter logs by a specific string (e.g. request ID or error keyword)
113+
aws logs filter-log-events \
114+
--log-group-name "/aws/bedrock-agentcore/runtimes/${AGENT_ID}-DEFAULT" \
115+
--filter-pattern '"ERROR"' \
116+
--region "$REGION"
117+
```

0 commit comments

Comments
 (0)