codeprobe-framework
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStandalone Mode
独立模式
If invoked directly (not via the orchestrator), you must first:
- Read for the output contract, execution modes, and constraints.
../codeprobe/shared-preamble.md - Load applicable reference files from based on the project's tech stack.
../codeprobe/references/ - Default to mode unless the user specifies otherwise.
full
如果直接调用(不通过编排器),您必须先执行以下步骤:
- 阅读,了解输出约定、执行模式和约束条件。
../codeprobe/shared-preamble.md - 根据项目技术栈,从加载适用的参考文件。
../codeprobe/references/ - 除非用户另行指定,默认使用模式。
full
Framework-Specific Best Practices
框架特定最佳实践
Domain Scope
领域范围
This sub-skill detects framework-specific anti-patterns and convention violations. Unlike other sub-skills that apply universal principles, this one loads framework-specific reference guides and checks against framework idioms.
Supported frameworks:
- PHP / Laravel — Eloquent ORM, routing, validation, queues, events, configuration
- React / Next.js — Component design, hooks, data fetching, type safety
- Python / Django / FastAPI — PEP conventions, ORM patterns, async handling
Important: If no supported framework is detected at the target path, emit zero findings and return an empty summary with a note: "No supported framework detected — skipping framework-specific checks."
Version Awareness: When checking framework conventions, attempt to determine the framework version:
- Laravel: check for
composer.jsonversion. Laravel 9+ uses attribute-based accessors instead oflaravel/framework.getXAttribute() - Next.js: check and
next.config.*for Next.js version. 13+ uses App Router withpackage.jsondirectory.app/ - Django: check or
requirements.txtfor Django version.setup.py
此子技能用于检测框架特定的反模式和规范违反。与其他应用通用原则的子技能不同,本技能会加载框架专属参考指南,并对照框架惯用用法进行检查。
支持的框架:
- PHP / Laravel — Eloquent ORM、路由、验证、队列、事件、配置
- React / Next.js — 组件设计、Hooks、数据获取、类型安全
- Python / Django / FastAPI — PEP规范、ORM模式、异步处理
重要提示: 如果在目标路径未检测到支持的框架,请输出零检测结果,并返回空摘要及说明:"未检测到支持的框架 — 跳过框架特定检查。"
版本感知: 检查框架规范时,尝试确定框架版本:
- Laravel: 在中查看
composer.json版本。Laravel 9+ 使用基于属性的访问器,而非laravel/framework。getXAttribute() - Next.js: 在和
next.config.*中查看Next.js版本。13+ 使用带package.json目录的App Router。app/ - Django: 在或
requirements.txt中查看Django版本。setup.py
What It Does NOT Flag
不标记的问题
- Issues already covered by other sub-skills even if they appear in framework code. Specifically:
- Security issues in framework code → covered by (SEC)
codeprobe-security - SOLID violations in framework classes → covered by (SRP/OCP/etc.)
codeprobe-solid - Performance issues like N+1 queries → covered by (PERF)
codeprobe-performance - Error handling in framework middleware → covered by (ERR)
codeprobe-error-handling
- Security issues in framework code → covered by
- This sub-skill focuses exclusively on framework idiom violations — using the framework incorrectly or ignoring its conventions.
- When this sub-skill and another sub-skill flag the same file:line range, the orchestrator's deduplication step (Section 7A) will keep the finding in whichever category is most relevant and mark the framework finding as a duplicate.
- Framework-generated boilerplate files (migration stubs, config defaults, scaffolded controllers).
- Intentional deviations from framework conventions with clear comments explaining the reason.
- Test files — test-specific framework usage has different conventions.
- 其他子技能已覆盖的问题,即使出现在框架代码中。具体包括:
- 框架代码中的安全问题 → 由(SEC)覆盖
codeprobe-security - 框架类中的SOLID原则违反 → 由(SRP/OCP等)覆盖
codeprobe-solid - 如N+1查询之类的性能问题 → 由(PERF)覆盖
codeprobe-performance - 框架中间件中的错误处理 → 由(ERR)覆盖
codeprobe-error-handling
- 框架代码中的安全问题 → 由
- 本子技能仅专注于框架惯用用法违反 —— 错误使用框架或忽略其规范。
- 当本子技能与其他子技能标记同一文件的同一行范围时,编排器的去重步骤(第7A节)将保留最相关分类的检测结果,并将框架检测结果标记为重复项。
- 框架生成的样板文件(迁移模板、配置默认值、脚手架控制器)。
- 故意偏离框架规范且有明确注释说明原因的情况。
- 测试文件 —— 测试场景下的框架使用有不同规范。
Detection Instructions
检测说明
PHP / Laravel
PHP / Laravel
| ID Prefix | Area | What to Detect | How to Detect | Severity |
|---|---|---|---|---|
| Eloquent | Raw queries where Eloquent query builder works | Search for | Minor |
| Eloquent | Missing | Model attributes that should be cast (dates, booleans, arrays, JSON) accessed without | Minor |
| Eloquent | Repeated WHERE conditions without scopes | Same | Minor |
| Routing | Logic in route closures instead of controllers | Route definitions in | Minor |
| Routing | Missing route model binding | Routes that accept an ID parameter and manually call | Minor |
| Validation | Validation in controller instead of Form Request | Controller methods with inline validation rules ( | Minor |
| Queues | Long-running tasks in request cycle | Operations likely to take > 5 seconds (sending emails, generating PDFs, calling external APIs, processing uploads) executed synchronously in a controller/request handler. Should be dispatched to a queue. | Major |
| Queues | Queue jobs without retry configuration | Job classes missing | Minor |
| Events | Tight coupling where events would decouple | After a state change (create, update, delete), a method directly calls 3+ other services. Should dispatch an event and let listeners handle side effects. | Minor |
| Config | | Using | Major |
| ID前缀 | 领域 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|---|
| Eloquent | 可使用Eloquent查询构建器却使用原生查询 | 在模型/服务代码中搜索 | 轻微 |
| Eloquent | 模型缺少 | 查看应进行类型转换(日期、布尔值、数组、JSON)的模型属性是否未定义 | 轻微 |
| Eloquent | 重复WHERE条件未使用作用域 | 同一模型中3处及以上位置使用相同的 | 轻微 |
| 路由 | 路由闭包中包含业务逻辑 | | 轻微 |
| 路由 | 缺少路由模型绑定 | 接收ID参数的路由,手动调用 | 轻微 |
| 验证 | 控制器中直接编写验证逻辑 | 控制器方法中的内联验证规则( | 轻微 |
| 队列 | 请求周期中执行长时间任务 | 在控制器/请求处理程序中同步执行可能耗时超过5秒的操作(发送邮件、生成PDF、调用外部API、处理上传),应将其分发至队列。 | 严重 |
| 队列 | 队列任务未配置重试机制 | 任务类缺少 | 轻微 |
| 事件 | 可通过事件解耦却存在紧耦合 | 状态变更(创建、更新、删除)后,某方法直接调用3个及以上其他服务,应分发事件并由监听器处理副作用。 | 轻微 |
| 配置 | 在配置文件外调用 | 在服务类、控制器或Blade模板中直接使用 | 严重 |
React / Next.js
React / Next.js
| ID Prefix | Area | What to Detect | How to Detect | Severity |
|---|---|---|---|---|
| Components | Components exceeding 200 LOC | Single component files with more than 200 lines of code. Should be decomposed into smaller, focused components. | Minor |
| Components | Prop drilling more than 3 levels deep | Props passed through 3+ intermediate components that don't use them. Should use Context, state management, or composition. Trace prop names through component hierarchy. | Minor |
| Hooks | | | Major |
| Hooks | State updates inside render | Calling | Major |
| Hooks | Custom hooks exceeding 50 LOC | Custom hooks that do too much. Should be composed from smaller hooks. | Minor |
| Data Fetching | Client-side fetch where SSR/SSG is appropriate | | Minor |
| Data Fetching | Missing error and loading states | Data fetching without corresponding loading indicator and error handling in the UI. | Minor |
| Type Safety | | Explicit | Minor |
| Type Safety | Missing return types on exported functions | Exported functions without explicit return type annotations. Rely on inference for internal, but exported API surfaces should be explicitly typed. | Minor |
| ID前缀 | 领域 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|---|
| 组件 | 组件代码超过200行 | 单个组件文件代码行数超过200行,应拆分为更小、职责单一的组件。 | 轻微 |
| 组件 | 属性穿透超过3层 | 属性经过3个及以上不使用该属性的中间组件传递,应使用Context、状态管理或组合模式。追踪属性名称在组件层级中的传递路径。 | 轻微 |
| Hooks | | | 严重 |
| Hooks | 渲染过程中更新状态 | 在事件处理程序或钩子之外直接调用 | 严重 |
| Hooks | 自定义Hooks超过50行 | 自定义Hooks功能过于复杂,应拆分为更小的Hooks组合实现。 | 轻微 |
| 数据获取 | 适合SSR/SSG却使用客户端获取 | 使用 | 轻微 |
| 数据获取 | 缺少错误和加载状态 | 数据获取逻辑未在UI中对应添加加载指示器和错误处理。 | 轻微 |
| 类型安全 | TypeScript中使用 | | 轻微 |
| 类型安全 | 导出函数缺少返回类型 | 导出函数未添加显式返回类型注解。内部函数可依赖类型推断,但导出的API接口应显式标注类型。 | 轻微 |
Python / Django / FastAPI
Python / Django / FastAPI
| ID Prefix | Area | What to Detect | How to Detect | Severity |
|---|---|---|---|---|
| Django | | Single view module with too many views. Should be split into separate view modules or use ViewSets. | Minor |
| Django | Missing model | Django models without | Minor |
| Django | N+1 in templates | Template tags accessing related objects without | Major |
| FastAPI | Sync database calls in async views | Using synchronous ORM calls (Django ORM, SQLAlchemy sync) inside | Major |
| Python | Non-PEP 8 naming | | Minor |
| ID前缀 | 领域 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|---|
| Django | | 单个视图模块包含过多视图,应拆分为多个视图模块或使用ViewSets。 | 轻微 |
| Django | 模型缺少 | Django模型未定义 | 轻微 |
| Django | 模板中的N+1查询 | 模板标签访问关联对象,但视图中未使用 | 严重 |
| FastAPI | 异步视图中使用同步数据库调用 | 在 | 严重 |
| Python | 不符合PEP 8命名规范 | 函数/变量使用 | 轻微 |
ID Prefix & Fix Prompt Examples
ID前缀及修复提示示例
All findings use the prefix, numbered sequentially: , , etc.
FWK-FWK-001FWK-002所有检测结果使用前缀,按顺序编号:、等。
FWK-FWK-001FWK-002Fix Prompt Examples
修复提示示例
- "Move the validation rules from (lines 15-30) into a new
OrderController@storeform request class: runStoreOrderRequest, move the validation array, and type-hintphp artisan make:request StoreOrderRequestin the controller method signature."StoreOrderRequest - "Replace the call at line 12 of
env('MAIL_HOST')withapp/Services/MailService.php. Theconfig('mail.mailers.smtp.host')function returnsenv()when the config is cached. Move the env lookup tonullwhere it belongs."config/mail.php - "The component at
ProductList(220 LOC) should be decomposed: extractsrc/components/ProductList.tsx(lines 50-90),ProductCard(lines 100-140), andProductFilters(lines 160-200) into separate components in the same directory."ProductPagination - "Add missing dependency to the
userIddependency array atuseEffect. The current empty arraysrc/hooks/useProfile.ts:15means the effect runs once with the initial[]and never refetches when it changes."userId
- "将(第15-30行)中的验证规则迁移至新的
OrderController@store表单请求类:执行StoreOrderRequest,迁移验证数组,并在控制器方法签名中添加php artisan make:request StoreOrderRequest类型提示。"StoreOrderRequest - "将第12行的
app/Services/MailService.php调用替换为env('MAIL_HOST')。配置缓存后config('mail.mailers.smtp.host')函数会返回env(),应将环境变量查找逻辑移至null中。"config/mail.php - "中的
src/components/ProductList.tsx组件(220行代码)应拆分:将ProductList(第50-90行)、ProductCard(第100-140行)和ProductFilters(第160-200行)提取为同一目录下的独立组件。"ProductPagination - "在的
src/hooks/useProfile.ts:15依赖数组中添加缺失的useEffect依赖。当前的空数组userId意味着该钩子仅在初始[]时执行一次,当userId变化时不会重新获取数据。"userId