trace-request-lifecycle

Trace the full request lifecycle from router through middleware, controller, use case, and repository to the response. Records relevant information such as HTTP method, route, middleware stack, response codes, and error handling paths.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "trace-request-lifecycle" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-d859b79202b0d1016b33c90ade6eaedc8967a5736ae87157f16400afe888af90. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Trace the full request lifecycle from router through middleware, controller, use case, and repository to the response. Records relevant information such as HTTP method, route, middleware stack, response codes, and error handling paths.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Traces full request lifecycle from Router through Middleware, Controller, UseCase, Repository to Response. Documents HTTP methods, routes, middleware stack, response codes, and error handling paths.
Inputs and outputs
```markdown
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: trace-request-lifecycle
description: Traces full request lifecycle from Router through Middleware, Controller, UseCase, Repository to Response. Documents HTTP methods, routes, middleware stack, response codes, and error handling paths.

Request Lifecycle Tracer

Overview

Traces the complete lifecycle of an HTTP request or CLI command through all application layers — from entry point through middleware, handler, business logic, persistence, and back to response. Documents the full chain with data transformations at each step.

Tracing Process

Step 1: Identify the Request Entry

# Find route definition for the target endpoint
Grep: "#\\[Route\\(" --glob "**/*.php" -A 2
Grep: "Route::(get|post|put|delete)" --glob "**/routes/*.php"

# Find the handler for this route
# Read the route config or controller to identify the handler method

Step 2: Trace Middleware Stack

# Symfony middleware (event listeners on kernel.request)
Grep: "kernel.request|kernel.controller|kernel.response" --glob "**/*.php"
Grep: "implements EventSubscriberInterface" --glob "**/*.php"

# Laravel middleware
Grep: "class.*Middleware" --glob "**/Middleware/**/*.php"
Grep: "'middleware'" --glob "**/Kernel.php"

# PSR-15 middleware
Grep: "implements MiddlewareInterface" --glob "**/*.php"

# Authentication middleware
Grep: "authenticat|JWT|Bearer|token" --glob "**/Middleware/**/*.php"

# Authorization middleware
Grep: "authoriz|permission|role|access" --glob "**/Middleware/**/*.php"

Step 3: Trace Controller/Action

# Read the handler method
Read: controller/action file

# Find what it receives (Request object/DTO)
Grep: "function.*\\(.*Request|function.*\\(.*DTO|function.*\\(.*Command" in handler

# Find what it calls (service/use case)
Grep: "\\$this->.*->handle|\\$this->.*->execute|\\$this->.*->dispatch" in handler

# Find response construction
Grep: "return.*Response|return.*JsonResponse|return.*json\\(" in handler

Step 4: Trace Use Case / Service

# Read the use case/service method
Read: use case file

# Find domain operations
Grep: "\\$this->.*Repository->find|\\$this->.*->save" in use case

# Find domain method calls
Grep: "\\$.*->create|\\$.*->update|\\$.*->process" in use case

# Find event dispatching
Grep: "dispatch|publish|raise" in use case

Step 5: Trace Repository Operations

# Read repository implementation
Grep: "implements.*Repository" --glob "**/Infrastructure/**/*.php"

# Find query patterns
Grep: "->createQueryBuilder|->find\\(|->findOneBy" in repository

# Find persistence operations
Grep: "->persist|->flush|->save|->insert|->update" in repository

Step 6: Trace Response Construction

# Response mapping
Grep: "->toArray|->toResponse|->jsonSerialize" in handler/response class

# Error responses
Grep: "ExceptionListener|ExceptionHandler|ErrorHandler" --glob "**/*.php"

# HTTP status codes used
Grep: "Response\\(.*[0-9]{3}|status.*[0-9]{3}|HTTP_" --glob "**/*.php"

Output Format

## Request Lifecycle

### Endpoint: POST /api/orders

#### Route Definition
- **Method:** POST
- **Path:** /api/orders
- **Controller:** `CreateOrderAction::__invoke`
- **Route file:** `config/routes/api.yaml:15`

#### Request Flow

Client Request (POST /api/orders, JSON body) │ ▼ [1] Router (matches POST /api/orders → CreateOrderAction) │ ▼ [2] Middleware Stack ├── CorsMiddleware — adds CORS headers ├── AuthenticationMiddleware — validates JWT token ├── RateLimitMiddleware — checks rate limits └── JsonRequestMiddleware — parses JSON body │ ▼ [3] Controller/Action: CreateOrderAction::__invoke(CreateOrderRequest $request) │ Input: CreateOrderRequest (validated DTO) │ - customerId: string (from JWT) │ - items: array [{productId, quantity}] │ - shippingAddress: {street, city, zip} │ ▼ [4] Use Case: CreateOrderUseCase::execute(CreateOrderCommand $command) │ Transforms: CreateOrderRequest → CreateOrderCommand │ ├── [4a] CustomerRepository::find(customerId) │ Returns: Customer entity │ ├── [4b] ProductRepository::findByIds(productIds) │ Returns: Product[] entities │ ├── [4c] Order::create(customer, items, address) │ Domain logic: validates, calculates total │ Raises: OrderCreated event │ ├── [4d] OrderRepository::save(order) │ Persists: INSERT into orders + order_items │ └── [4e] EventBus::dispatch(OrderCreated) Async: sends to message queue │ ▼ [5] Response Construction │ Transforms: Order entity → OrderResponse DTO │ OrderResponse: {id, status, total, items[], createdAt} │ ▼ [6] HTTP Response Status: 201 Created Headers: Content-Type: application/json, Location: /api/orders/{id} Body: {"id": "...", "status": "pending", "total": 150.00, ...}


#### Error Paths

| Error | Where | HTTP Status | Response |
|-------|-------|-------------|----------|
| Invalid JSON | Middleware [2] | 400 | {"error": "Invalid JSON"} |
| Unauthorized | Middleware [2] | 401 | {"error": "Token expired"} |
| Validation fail | Action [3] | 422 | {"errors": {"items": "..."}} |
| Customer not found | UseCase [4a] | 404 | {"error": "Customer not found"} |
| Out of stock | Domain [4c] | 409 | {"error": "Product out of stock"} |
| DB error | Repository [4d] | 500 | {"error": "Internal error"} |

#### Data Transformation Chain

JSON Body → CreateOrderRequest (DTO) → CreateOrderCommand (CQRS Command) → Order Entity (Domain) → OrderResponse (DTO) → JSON Response


#### Key Files in Chain

| Step | File | Line | Purpose |
|------|------|------|---------|
| Route | config/routes/api.yaml | 15 | Route definition |
| Action | src/Api/Action/CreateOrderAction.php | 22 | HTTP handler |
| Request | src/Api/Request/CreateOrderRequest.php | 1 | Input validation |
| Command | src/Application/Command/CreateOrderCommand.php | 1 | CQRS command |
| UseCase | src/Application/UseCase/CreateOrderUseCase.php | 15 | Orchestration |
| Entity | src/Domain/Order/Order.php | 45 | Domain logic |
| Repo | src/Infrastructure/Repository/DoctrineOrderRepo.php | 30 | Persistence |
| Response | src/Api/Response/OrderResponse.php | 1 | Output mapping |

Lifecycle Quality Indicators

Indicator Good Warning
Input validation At boundary (Request/DTO) In controller logic
Business logic In Domain/UseCase In controller
Error handling Exception handler Try-catch everywhere
Response mapping Dedicated Response class Array building in controller
Side effects Via events (async) Direct calls in handler

Integration

This skill is used by:

  • data-flow-analyst — provides lifecycle documentation
  • trace-data-transformation — traces DTO transformations
  • explain-business-process — maps processes to request flows

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value78/100

Highlights

  • 提供完整的请求生命周期追踪能力,覆盖从路由到响应的全链路分析
  • 支持多种主流框架(Symfony/Laravel/PSR-15),具有广泛适用性
  • 包含详细的错误处理路径和数据转换链文档
Trigger Precision85/100

Highlights

  • description 明确描述了功能范围和核心能力
  • 触发词覆盖合理,边界清晰,不易误触
Structure and Standards92/100

Highlights

  • Phase/步骤清晰(6 个步骤),逻辑连贯
  • 包含端到端完整示例,便于理解执行流程
  • frontmatter 完整,文档结构规范
Execution Reliability88/100

Highlights

  • 工具来源明确(Grep/Read 命令),参数正确
  • 覆盖主要异常场景(错误路径表格)
  • 无不可逆操作,执行安全可靠
Evidence Verifiability (mean of the first four)86/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.