This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Go CLI tool called kiro2cc that manages Kiro authentication tokens and provides an Anthropic API proxy service. The tool acts as a bridge between Anthropic API requests and AWS CodeWhisperer, translating requests and responses between the two formats.
# Build the application
go build -o kiro2cc main.go
# Run tests
go test ./...
# Run specific test in parser package
go test ./parser -v
# Run the application
./kiro2cc [command]./kiro2cc read- Read and display token information./kiro2cc refresh- Refresh the access token using refresh token./kiro2cc export- Export environment variables for other tools./kiro2cc server [port]- Start HTTP proxy server (default port 8080)
-
Token Management (
main.go:337-486)- Reads tokens from
~/.aws/sso/cache/kiro-auth-token.json - Handles token refresh via Kiro auth service
- Cross-platform environment variable export
- Reads tokens from
-
API Translation (
main.go:232-303)- Converts Anthropic API requests to CodeWhisperer format
- Maps model names via
ModelMap(line 218-221) - Handles conversation history and system messages
-
HTTP Proxy Server (
main.go:514-893)- Serves on
/v1/messagesendpoint - Supports both streaming and non-streaming requests
- Automatic token refresh on 403 errors
- Serves on
-
Response Parser (
parser/sse_parser.go)- Parses binary CodeWhisperer responses
- Converts to Anthropic-compatible SSE events
- Handles tool use and text content blocks
AnthropicRequest- Incoming API requestsCodeWhispererRequest- Outgoing AWS requestsTokenData- Authentication token storageSSEEvent- Streaming response events
- Client sends Anthropic API request to
/v1/messages - Server reads token from filesystem
- Request converted to CodeWhisperer format
- Proxied to AWS CodeWhisperer API
- Response parsed and converted back to Anthropic format
- Streamed or returned as JSON to client
- Uses hardcoded proxy
127.0.0.1:9000for AWS requests - Model mapping required between Anthropic and CodeWhisperer model IDs
- Response files saved as
msg_[timestamp]response.rawfor debugging - Automatic token refresh on authentication failures