trace-request-lifecycle

跟踪完整请求生命周期,从路由器到中间件、控制器、用例、存储库直至响应。记录 HTTP 方法、路由、中间件栈、响应码及错误处理路径的相关信息。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "trace-request-lifecycle":https://skillpi.com/zh/skills/deepskill-d859b79202b0d1016b33c90ade6eaedc8967a5736ae87157f16400afe888af90。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

跟踪完整请求生命周期,从路由器到中间件、控制器、用例、存储库直至响应。记录 HTTP 方法、路由、中间件栈、响应码及错误处理路径的相关信息。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
输入和输出
减记
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
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

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值78/100

亮点

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

亮点

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

亮点

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

亮点

  • 工具来源明确(Grep/Read 命令),参数正确
  • 覆盖主要异常场景(错误路径表格)
  • 无不可逆操作,执行安全可靠
证据可验 (前四项均值)86/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

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

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。