|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +YOLO is a PHP CLI tool for deploying Laravel applications to AWS. It provisions and manages AWS resources (VPCs, EC2, |
| 8 | +ALB, autoscaling groups, CodeDeploy, S3, etc.) and handles zero-downtime deployments. |
| 9 | + |
| 10 | +## Rules |
| 11 | +- |
| 12 | + |
| 13 | +- Always format code with pint after making changes |
| 14 | +- Always run tests before pushing changes |
| 15 | + |
| 16 | +## Commands |
| 17 | + |
| 18 | +```bash |
| 19 | +# Run tests |
| 20 | +./vendor/bin/pest |
| 21 | + |
| 22 | +# Run a single test file |
| 23 | +./vendor/bin/pest tests/Arch/StepsTest.php |
| 24 | + |
| 25 | +# Run a specific test |
| 26 | +./vendor/bin/pest --filter "test name" |
| 27 | + |
| 28 | +# Static analysis |
| 29 | +./vendor/bin/phpstan analyse |
| 30 | + |
| 31 | +# Code formatting |
| 32 | +./vendor/bin/pint |
| 33 | +``` |
| 34 | + |
| 35 | +## Architecture |
| 36 | + |
| 37 | +### Entry Point |
| 38 | + |
| 39 | +- `yolo` - CLI entry script that bootstraps the Symfony Console application |
| 40 | +- `src/Yolo.php` - Registers all commands with the Symfony Application |
| 41 | + |
| 42 | +### Commands (`src/Commands/`) |
| 43 | + |
| 44 | +All commands extend `Command` (base class) or `SteppedCommand` (for multi-step operations). |
| 45 | + |
| 46 | +- **Base Command** (`Command.php`) - Handles AWS authentication, environment validation, and manifest checks |
| 47 | +- **SteppedCommand** - Executes a series of `Step` classes with progress tracking and status reporting |
| 48 | + |
| 49 | +Key commands: `build`, `deploy`, `sync`, `sync:network`, `sync:compute`, `sync:standalone`, `sync:tenant`, `stage`, |
| 50 | +`image:create`, `env:push`, `env:pull` |
| 51 | + |
| 52 | +### Steps (`src/Steps/`) |
| 53 | + |
| 54 | +Steps are the atomic units of work. Each step implements the `Step` interface and returns a `StepResult` enum. |
| 55 | + |
| 56 | +Steps are organized by domain: |
| 57 | + |
| 58 | +- `Build/` - Build process steps |
| 59 | +- `Deploy/` - Deployment steps |
| 60 | +- `Network/` - VPC, subnet, security group provisioning |
| 61 | +- `Compute/` - EC2, autoscaling setup |
| 62 | +- `Iam/` - IAM roles and policies |
| 63 | +- `Standalone/` / `Tenant/` / `Landlord/` - App-type specific steps |
| 64 | + |
| 65 | +### Contracts (`src/Contracts/`) |
| 66 | + |
| 67 | +Interfaces that steps implement to indicate execution context: |
| 68 | + |
| 69 | +- `RunsOnBuild` - Runs during local build |
| 70 | +- `RunsOnAws` - Runs on AWS instances |
| 71 | +- `RunsOnAwsQueue` / `RunsOnAwsScheduler` / `RunsOnAwsWeb` - Runs on specific worker groups |
| 72 | +- `ExecutesTenantStep` - Runs once per tenant in multi-tenant apps |
| 73 | +- `HasSubSteps` - Step contains sub-steps (e.g., manifest build commands) |
| 74 | + |
| 75 | +### Concerns (`src/Concerns/`) |
| 76 | + |
| 77 | +Traits for AWS service interactions: `UsesEc2`, `UsesIam`, `UsesAutoscaling`, `UsesCodeDeploy`, `UsesRoute53`, etc. |
| 78 | + |
| 79 | +### Configuration |
| 80 | + |
| 81 | +- `Manifest.php` - Reads/writes `yolo.yml` configuration |
| 82 | +- `Paths.php` - Centralizes file path resolution |
| 83 | +- `Helpers.php` - Utility functions and container access |
| 84 | + |
| 85 | +### Key Patterns |
| 86 | + |
| 87 | +1. Commands define a `$steps` array of Step classes to execute |
| 88 | +2. `RunsSteppedCommands` trait handles step execution with progress UI |
| 89 | +3. AWS SDK clients are registered via `RegistersAws` trait based on environment |
| 90 | +4. Multi-tenancy is supported through tenant-aware steps that iterate over `Manifest::tenants()` |
0 commit comments