This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a TypeScript monorepo containing CLI tools for the Fiftyten platform ecosystem. The tools are designed to streamline database connectivity and operational tasks through AWS Session Manager integration.
- Monorepo Structure: pnpm workspaces with packages in
packages/directory - Primary Tool:
@fiftyten/db-toolkit- AWS Session Manager-based database toolkit - Target Deployment: Published to npm as scoped packages under
@fiftyten/ - AWS Integration: Heavy use of AWS SDK v3 (EC2, SSM, Secrets Manager, IAM)
- db-toolkit: Complete database toolkit with connections, migration, MFA support, and DynamoDB operations
# Install dependencies for all packages
pnpm install
# Build all packages
pnpm build
# Run tests across all packages
pnpm test
# Lint all packages
pnpm lint
# Format all packages
pnpm format
# Clean all build artifacts
pnpm clean# Work with specific package
pnpm --filter db-toolkit build
pnpm --filter db-toolkit dev # Watch mode compilation
pnpm --filter db-toolkit test
# Install dependencies for specific package
pnpm --filter db-toolkit install <package># Test db-connect locally after building
node packages/db-toolkit/bin/fiftyten-db.js --help
# Test with pnpm dlx (without global install)
pnpm dlx @fiftyten/db-toolkit psql dev -d indicator# Publish all changed packages
pnpm publish-packages
# Publish specific package
pnpm --filter db-toolkit publish --access publicEach tool follows this structure:
package.json- Package configuration withbinentries for CLI commandssrc/index.ts- Main CLI entry point using Commander.jssrc/- Source modules (TypeScript)bin/- Compiled executable filestsconfig.json- TypeScript configuration extending root config
- Commander.js: CLI framework for argument parsing and command structure
- AWS SDK v3: Modular AWS service clients (EC2, SSM, Secrets Manager, IAM)
- Chalk: Terminal output coloring
- Inquirer: Interactive prompts for MFA and user input
- Credential Chain: Supports AWS profiles, IAM roles, environment variables
- MFA Authentication: Automatic device discovery with session token management
- Session Manager: Port forwarding for secure database connections without SSH keys
- Secrets Manager: Automatic password retrieval for database connections
- Parameter Store: Configuration storage for environment-specific settings
- Environment Resolution: Maps environment (dev/main) to AWS infrastructure
- MFA Authentication: Auto-discovers MFA devices, prompts for token
- Instance Discovery: Finds bastion hosts via EC2 tags
- Parameter Retrieval: Gets database configuration from SSM Parameter Store
- Secret Retrieval: Fetches database passwords from Secrets Manager
- Tunnel Creation: Establishes Session Manager port forwarding
- Connection: Launches psql with automatic credentials
- Use Commander.js with consistent argument/option patterns
- Environment argument:
<environment>(dev/main) - Database option:
-d, --database <app>(platform, copytrading) - Port option:
-p, --port <port>with intelligent defaults - Region option:
--region <region>defaulting to us-west-1
- Target ES2020 with CommonJS modules
- Strict mode enabled with full type checking
- Source maps and declarations generated for debugging
- JSON module resolution for package.json imports
- Use chalk for colored error output
- Exit with appropriate codes (0 for success, 1 for errors)
- Provide helpful error messages with suggested solutions
- Handle AWS credential/permission errors gracefully
- Include
--versionand--helpflags - Use consistent command naming (
fiftyten-prefix) - Provide descriptive help text and examples
- Support both short and long option formats
- Use AWS SDK v3 modular imports to minimize bundle size
- Never hardcode credentials or sensitive information
- Implement proper credential chain support
- Handle MFA requirements transparently
- Use least-privilege IAM permissions
- Follow existing TypeScript patterns and naming conventions
- Maintain clear separation between CLI interface and core logic
- Use dependency injection for AWS clients to enable testing
- Include comprehensive error messages and user guidance
- Create new directory under
packages/ - Initialize with
package.jsonincluding:- Scoped name
@fiftyten/tool-name - Binary entries in
binfield - Proper scripts (build, dev, prepublishOnly)
- Scoped name
- Add TypeScript configuration extending root config
- Implement CLI using Commander.js pattern
- Add package reference to root
tsconfig.json
- Version bumps required for publishing
prepublishOnlyscript must build successfully- Public access configuration for scoped packages
- GitHub repository and bug tracking URLs
- Use Node.js native test capabilities or Jest
- Test CLI commands with actual AWS integration (when appropriate)
- Mock AWS services for unit testing core logic
- Include integration tests for critical user workflows