This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Format code
make fmt
# Run tests with coverage
make test
# Run linter
make lint
# Build the CLI (via go build)
go build -o apppack main.go# Run a specific test file
go test ./app -v
# Run a specific test function
go test ./app -run TestSpecificFunction -v
# Run tests with coverage for a specific package
go test ./stacks -cover -coverprofile=coverage.outThis is a Go CLI application for managing cloud infrastructure via AppPack.io. The codebase follows a modular, interface-based architecture:
- cmd/: CLI commands using Cobra framework. Each command follows the pattern: authentication → AWS session → stack operations → user feedback
- app/: Application lifecycle management including ECS tasks, builds, configuration, and shell access via AWS Session Manager
- stacks/: Infrastructure abstraction layer with common Stack interface for CloudFormation operations across different resource types (clusters, databases, domains, etc.)
- auth/: OAuth-based authentication with Auth0, JWT token management, and AWS session creation via role assumption
- bridge/: AWS service integration wrappers for CloudFormation, EC2, Route53
- aws/: Low-level AWS SDK utilities for EventBridge, SSM
The Stack interface in stacks/interfaces.go defines the contract for all infrastructure types:
GetParameters(): CloudFormation parameter marshalingStackName(),TemplateURL(): Resource naming and template resolutionAskQuestions(): Interactive parameter collection- Lifecycle hooks:
PostCreate(),PreDelete(),PostDelete()
- OAuth device code flow for CLI-friendly auth (no browser required)
- JWT tokens stored in filesystem cache with automatic refresh
- AWS STS role assumption for temporary credentials
- Session creation with proper region configuration
All infrastructure follows this lifecycle:
- Parameter validation and collection (flags or interactive prompts)
- CloudFormation template URL resolution
- Changeset creation for preview
- Stack creation/update with progress tracking
- Post-deployment hooks for additional setup
- Use
github.com/stretchr/testifyfor test assertions - Mock AWS services using interfaces defined in the codebase
- Test files should be co-located with source files (
*_test.go) - Use table-driven tests for testing multiple scenarios
Use the checkErr() function from cmd/root.go for consistent CLI error reporting with colored output.
Always use the session from the App struct (app.Session) for AWS SDK calls. The session includes proper authentication and region configuration.
- Use
github.com/AlecAivazis/survey/v2for interactive prompts - Use
github.com/briandowns/spinnerfor long-running operations - Use
github.com/logrusorgru/aurorafor colored terminal output
When adding new stack types:
- Define struct with CloudFormation parameter tags
- Implement
Parametersinterface methods - Use reflection-based parameter conversion in
stacks/utils.go
Enable debug logging with the --debug flag on any command. This will show detailed AWS API calls and internal operation logs via logrus.
The project uses GoReleaser with GitHub Actions:
- Update CHANGELOG.md with release notes
- Tag commit with version (e.g.,
git tag -s v4.6.7) - Push tag (
git push --tag) - GoReleaser automatically builds and releases cross-platform binaries