map-async-flows
Async Flow Mapper
Overview
Identifies all asynchronous communication patterns in the codebase — message queues, event dispatching, webhooks, scheduled tasks, and background jobs. Documents the sync-to-async boundaries, message formats, consumer chains, and error handling strategies.
Detection Patterns
Message Queue Publishing
# RabbitMQ (php-amqplib, Symfony Messenger)
Grep: "AMQPMessage|AMQPChannel|AMQPConnection" --glob "**/*.php"
Grep: "basic_publish|queue_declare|exchange_declare" --glob "**/*.php"
# Symfony Messenger
Grep: "MessageBusInterface|->dispatch\\(" --glob "**/*.php"
Grep: "#\\[AsMessageHandler\\]" --glob "**/*.php"
Grep: "Envelope|Stamp" --glob "**/*.php"
# Laravel Queue
Grep: "implements ShouldQueue" --glob "**/*.php"
Grep: "dispatch\\(new|Queue::push" --glob "**/*.php"
# Redis queues
Grep: "Redis::.*push|->lpush|->rpush" --glob "**/*.php"
Grep: "Predis|PhpRedis|redis" --glob "**/*.php"
# Generic publish patterns
Grep: "->publish\\(|->enqueue\\(|->sendToQueue" --glob "**/*.php"
Event Dispatching
# Symfony EventDispatcher
Grep: "EventDispatcherInterface|->dispatch\\(" --glob "**/*.php"
Grep: "#\\[AsEventListener\\(" --glob "**/*.php"
Grep: "implements EventSubscriberInterface" --glob "**/*.php"
# Domain Events
Grep: "DomainEvent|->recordEvent|->raise" --glob "**/Domain/**/*.php"
Grep: "EventBus|DomainEventPublisher" --glob "**/*.php"
# Laravel Events
Grep: "event\\(new|Event::dispatch" --glob "**/*.php"
Grep: "class.*Listener" --glob "**/Listeners/**/*.php"
Webhooks
# Outgoing webhooks
Grep: "webhook|Webhook" --glob "**/*.php"
Grep: "->post\\(.*callback|->send.*notification" --glob "**/*.php"
# Incoming webhook handlers
Grep: "function.*webhook|#\\[Route.*webhook" --glob "**/*.php"
# Webhook retry/delivery tracking
Grep: "WebhookDelivery|delivery_attempts|retry_after" --glob "**/*.php"
Scheduled Tasks / Cron
# Symfony Scheduler
Grep: "#\\[AsCronTask\\]|#\\[AsPeriodicTask\\]" --glob "**/*.php"
Grep: "RecurringMessage|Schedule" --glob "**/*.php"
# Laravel Scheduler
Grep: "->command\\(|->call\\(|->job\\(" --glob "**/Console/Kernel.php"
# Custom schedulers
Grep: "cron|schedule|periodic|interval" --glob "config/**/*.{php,yaml,yml}"
Background Jobs
# Process forking
Grep: "pcntl_fork|proc_open|Process::" --glob "**/*.php"
# Async operations
Grep: "async|promise|Future|Deferred" --glob "**/*.php"
# Worker patterns
Grep: "class.*Worker|class.*Consumer|class.*Processor" --glob "**/*.php"
Grep: "function consume|function process|function work" --glob "**/*.php"
Analysis Process
Step 1: Map Sync-Async Boundaries
For each message/event dispatch found:
- Read the publisher — what triggers the async operation
- Read the message class — what data is sent
- Find the consumer/handler — what processes the message
- Check transport config — queue name, exchange, routing
Step 2: Trace Consumer Chains
Event Published → Handler 1 → may publish Event 2 → Handler 2 → ...
# Find what handlers dispatch
Grep: "->dispatch\\(|->publish\\(" --glob "**/Handler/**/*.php"
Grep: "->dispatch\\(|->publish\\(" --glob "**/Listener/**/*.php"
Step 3: Document Error Handling
# Retry configuration
Grep: "retry|RetryStrategy|maxRetries|max_retries" --glob "**/*.php"
Grep: "retry:" --glob "config/**/*.yaml"
# Dead letter queue
Grep: "dead_letter|failed_queue|DLQ" --glob "**/*.php"
Grep: "dead_letter" --glob "config/**/*.yaml"
# Error handling in consumers
Grep: "catch.*Exception|->reject|->nack" --glob "**/Handler/**/*.php"
Output Format
## Async Communication Map
### Overview
| Type | Count | Transport |
|------|-------|-----------|
| Queue Messages | 8 | RabbitMQ (Symfony Messenger) |
| Domain Events | 12 | In-process + async relay |
| Webhooks (outgoing) | 3 | HTTP POST |
| Scheduled Tasks | 5 | Symfony Scheduler |
### Sync-Async Boundaries
[Sync World] [Async World]
CreateOrderUseCase ├── save(order) └── dispatch(OrderCreated) ──→ Queue: "orders" ├── SendConfirmationEmail ├── ReserveInventory └── NotifyAnalytics
ProcessPayment └── dispatch(PaymentReceived)→ Queue: "payments" ├── UpdateOrderStatus └── SendReceipt
### Message Catalog
| Message | Publisher | Consumer(s) | Queue | Async |
|---------|-----------|-------------|-------|-------|
| OrderCreated | CreateOrderUseCase | EmailHandler, InventoryHandler | orders | Yes |
| PaymentReceived | PaymentService | OrderStatusHandler, ReceiptHandler | payments | Yes |
| UserRegistered | RegisterUseCase | WelcomeEmailHandler | users | Yes |
| DailyReport | Scheduler (02:00) | ReportGenerator | reports | Yes |
### Consumer Chains
OrderCreated └── InventoryHandler └── dispatches: InventoryReserved └── WarehouseHandler └── dispatches: PackingStarted
### Queue Configuration
| Queue | Exchange | Routing Key | Consumers | Prefetch |
|-------|----------|-------------|-----------|----------|
| orders | order_exchange | order.* | 3 | 10 |
| payments | payment_exchange | payment.# | 2 | 5 |
| notifications | notify_exchange | notify.email | 5 | 20 |
### Error Handling
| Message | Retry | Max Attempts | Dead Letter | Fallback |
|---------|-------|-------------|-------------|----------|
| OrderCreated | Exponential backoff | 3 | orders_dlq | Log + Alert |
| PaymentReceived | Fixed delay 5s | 5 | payments_dlq | Manual review |
| EmailNotification | Fixed delay 10s | 3 | None | Silent drop |
### Scheduled Tasks
| Schedule | Task | Description | Duration |
|----------|------|-------------|----------|
| 0 2 * * * | DailyReportCommand | Generate daily reports | ~5 min |
| */5 * * * * | HealthCheckCommand | Service health check | ~10 sec |
| 0 0 * * 0 | CleanupCommand | Remove expired data | ~15 min |
### Webhook Endpoints
| Direction | URL/Endpoint | Trigger | Payload |
|-----------|-------------|---------|---------|
| Outgoing | partner-api/notify | OrderShipped | {orderId, trackingNo} |
| Incoming | /webhooks/payment | Payment provider | {transactionId, status} |
Async Flow Quality Indicators
| Indicator | Good | Warning |
|---|---|---|
| Message idempotency | Handlers are idempotent | No deduplication |
| Error handling | Retry + DLQ + alerting | Silent failure |
| Message format | Typed message classes | Array/JSON strings |
| Consumer isolation | Each handler does one thing | Handler chains in one |
| Monitoring | Queue depth metrics | No monitoring |
Integration
This skill is used by:
data-flow-analyst— documents async communication pathstrace-request-lifecycle— identifies where sync becomes asyncexplain-business-process— shows async steps in workflows
More from dykyi-roman/awesome-claude-code
psr-overview-knowledge
PHP Standards Recommendations (PSR) overview knowledge base. Provides comprehensive reference for all accepted PSRs including PSR-1,3,4,6,7,11,12,13,14,15,16,17,18,20. Use for PSR selection decisions and compliance audits.
22detect-code-smells
Detects code smells in PHP codebases. Identifies God Class, Feature Envy, Data Clumps, Long Parameter List, Long Method, Primitive Obsession, Message Chains, Inappropriate Intimacy. Generates actionable reports with refactoring recommendations.
15clean-arch-knowledge
Clean Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Clean Architecture and Hexagonal Architecture audits.
15ddd-knowledge
DDD architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Domain-Driven Design audits.
14testing-knowledge
Testing knowledge base for PHP 8.4 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.
12bug-root-cause-finder
Root cause analysis methods for PHP bugs. Provides 5 Whys technique, fault tree analysis, git bisect guidance, and stack trace parsing.
12