Skip to content

feat(skills): add EventBus and AOP skill content#5835

Merged
gxkl merged 6 commits intonextfrom
feat/skills-eventbus-aop
Mar 18, 2026
Merged

feat(skills): add EventBus and AOP skill content#5835
gxkl merged 6 commits intonextfrom
feat/skills-eventbus-aop

Conversation

@gxkl
Copy link
Copy Markdown
Contributor

@gxkl gxkl commented Mar 17, 2026

Summary

  • Fix technical inaccuracies and naming issues in existing skill docs based on review feedback
  • Add EventBus skill content to egg-core (reference doc + SKILL.md decision tree + entry routing)
  • Add AOP skill content to egg-core (reference doc covering Advice/Pointcut/Crosscut/order + SKILL.md decision tree + entry routing)
  • Restructure egg-core SKILL.md with clear sections: "代码组织与依赖注入" and "异步任务" and "AOP 切面编程"
  • Add 17 eval cases (EventBus 7 + AOP 8 + routing 2) with iteration-5 results

Test plan

  • EventBus evals: with-skill 26/26 (100%) vs site-docs 19/26 (73%)
  • AOP evals: with-skill 23/23 (100%) vs site-docs 19/23 (83%)
  • Total: with-skill 49/49 (100%) vs site-docs 38/49 (78%)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added comprehensive guides for EventBus (event-driven patterns), AOP (advice/pointcut/crosscut), and BackgroundTask behavior; improved Ajv/TypeBox parameter-validation guidance, examples, and best practices; reorganized skill docs and examples to reflect updated naming and paths.
  • New Features

    • Added new evaluation and routing entries covering EventBus, AOP, background-task vs EventBus decisions, and parameter-validation scenarios.

gxkl and others added 5 commits March 17, 2026 23:33
- Fix skill directory naming: controller/ → egg-controller/ (3 places)
- Fix /ant-skill-creator → /skill-creator reference (2 places)
- Add text language specifier to fenced code blocks (3 places)
- Update skill descriptions with new capabilities (background task, Ajv)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
background-task.md:
- Fix run() execution timing: task starts immediately, not deferred
  to after response. Framework waits at Context preDestroy
- Fix error log format: no space after colon to match implementation

ajv-validate.md:
- Fix example file path to match module directory convention
- Remove hardcoded 422 status from AjvInvalidParamError description

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- egg/SKILL.md: add ajv/validate/schema keywords to controller routing,
  add background task to core routing, update quick reference table and
  protocol/use-case table
- egg-core/SKILL.md: add BackgroundTaskHelper to description
- egg-controller/SKILL.md: add Ajv/TypeBox validation to description

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add EventBus reference doc to egg-core skill covering usage patterns,
common errors, cork/uncork, testing with EventWaiter, and type-safe
event declarations. Restructure SKILL.md with "代码组织与依赖注入"
and "异步任务" sections, adding BackgroundTaskHelper vs EventBus
comparison table. Update entry skill routing for EventBus keywords.
Add 7 EventBus eval cases (id 27-33) and 2 routing eval cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add AOP reference doc to egg-core skill covering Advice lifecycle,
Pointcut vs Crosscut selection, three Crosscut matching modes (CLASS,
NAME, CUSTOM), execution order with order parameter, and adviceParams.
Update SKILL.md with AOP decision tree and entry skill routing.
Add 8 AOP eval cases (id 34-41) and 1 routing eval case.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 17, 2026 16:51
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

This PR updates skill documentation paths (/ant-skill-creator/skill-creator, controller/egg-controller/), expands egg-core guidance with EventBus and AOP content, adds Ajv/TypeBox parameter-validation coverage in egg-controller, and appends related evaluation and routing cases for egg-core.

Changes

Cohort / File(s) Summary
Directory Reference Refactoring
packages/skills/CLAUDE.md
Replaced /ant-skill-creator with /skill-creator; renamed controller/ references to egg-controller/ across guidance and examples.
egg-controller Skill Expansion
packages/skills/egg-controller/SKILL.md, packages/skills/egg-controller/references/ajv-validate.md
Extended SKILL description to include Ajv/TypeBox parameter validation for HTTP/MCP/Schedule controllers; updated example controller path and validation wording.
egg-core Skill Documentation
packages/skills/egg-core/SKILL.md
Reorganized DI and code-organization sections; added BackgroundTaskHelper, EventBus, and AOP guidance, usage patterns, and decision flow examples.
egg-core New Reference Guides
packages/skills/egg-core/references/aop.md, packages/skills/egg-core/references/eventbus.md
Added AOP reference (Advice, Pointcut, Crosscut, lifecycle, examples) and EventBus guide (typing, emit/handler patterns, cork/uncork, testing).
egg-core Background Task Updates
packages/skills/egg-core/references/background-task.md
Clarified BackgroundTaskHelper.run() semantics: immediate start, non-blocking, end-of-request sync with context waiting and timeout.
Main Skill Overview
packages/skills/egg/SKILL.md
Expanded egg SKILL to list EventBus, AOP, Background tasks, and Ajv parameter validation in capability/decision tables and examples; updated routing logic.
Evaluation Test Cases
packages/skills/eval/evals-egg-core.json, packages/skills/eval/evals-routing.json
Appended new egg-core evals (ids 27–41) covering EventBus and AOP scenarios; added routing evals (ids 9–11) to route new prompts to egg-core.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • akitaSummer
  • killagu
  • fengmk2

Poem

🐰 I nibble docs and hop along,
Paths aligned and sections strong,
Events flutter, advices sing,
Validation checks — a tidy spring,
Hooray, the skills now dance in sync!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(skills): add EventBus and AOP skill content' directly and accurately describes the main changes in the PR, which focus on adding new EventBus and AOP documentation and skill content to egg-core.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/skills-eventbus-aop
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the capabilities of the AI agent skills for the Egg framework by integrating detailed documentation for EventBus and Aspect-Oriented Programming (AOP). It also addresses existing documentation inaccuracies and improves naming conventions, particularly for controller-related skills. The changes aim to provide a more robust and comprehensive knowledge base, enabling the AI agent to offer better guidance on advanced architectural patterns and cross-cutting concerns within Egg applications, all validated through new evaluation scenarios.

Highlights

  • Skill Documentation Refinement: Technical inaccuracies and naming issues in existing skill documentation were fixed based on review feedback, improving clarity and correctness.
  • EventBus Skill Content Added: Comprehensive EventBus skill content was added to egg-core, including a detailed reference document, a decision tree in SKILL.md, and updated entry routing.
  • AOP Skill Content Added: New AOP skill content was introduced to egg-core, covering core concepts like Advice, Pointcut, Crosscut, and execution order, along with a decision tree and entry routing.
  • Egg-Core SKILL.md Restructuring: The egg-core/SKILL.md file was restructured into clear sections: '代码组织与依赖注入' (Code Organization and Dependency Injection), '异步任务' (Asynchronous Tasks), and 'AOP 切面编程' (AOP Aspect Programming) for better organization.
  • New Evaluation Cases: Seventeen new evaluation cases were added to validate the new EventBus (7 cases) and AOP (8 cases) content, and two cases for routing, ensuring the AI agent can correctly utilize the new skills.
Changelog
  • packages/skills/CLAUDE.md
    • Updated references to skill creator from /ant-skill-creator to /skill-creator.
    • Expanded descriptions for egg-core/ and egg-controller/ skills to include new concepts like '后台任务' and 'Ajv 校验'.
    • Renamed controller/ to egg-controller/ in skill architecture and organization tables.
    • Modified instructions for adding new skills and references to reflect the updated skill names and creator tool.
    • Added text to code block fences for improved markdown rendering of evaluation file structures and environment descriptions.
  • packages/skills/egg-controller/SKILL.md
    • Updated the skill description to explicitly mention 'adding parameter validation' and 'Ajv/TypeBox parameter validation'.
  • packages/skills/egg-controller/references/ajv-validate.md
    • Updated the example controller file path from app/modules/demo/FooController.ts to app/userModule/UserController.ts.
    • Refined the comment regarding AjvInvalidParamError by removing the specific HTTP status code (422).
    • Clarified the advice for using Type.Optional() to prevent '校验失败' (validation failure) instead of '422'.
  • packages/skills/egg-core/SKILL.md
    • Expanded the skill description to include BackgroundTaskHelper (后台任务), EventBus (事件总线), and AOP (切面编程).
    • Restructured the document with new top-level sections: '代码组织与依赖注入', '异步任务', and 'AOP 切面编程', and adjusted sub-headings accordingly.
    • Updated the '快速决策指南' (Quick Decision Guide) by removing the asynchronous task row and adding a new comparative table for '异步任务' (Asynchronous Tasks) between BackgroundTaskHelper and EventBus.
    • Introduced a new section for 'AOP 切面编程' (AOP Aspect Programming) with a decision tree for Pointcut and Crosscut.
    • Added new reference links for eventbus.md and aop.md.
  • packages/skills/egg-core/references/aop.md
    • Added a new comprehensive reference document for AOP Aspect Programming, covering common errors, core concepts (Advice, AdviceContext), Pointcut vs Crosscut, execution order, parameter passing, and typical scenarios.
  • packages/skills/egg-core/references/background-task.md
    • Clarified the behavior of BackgroundTaskHelper.run(), stating that tasks start immediately but do not block the current flow, and the framework waits for their completion.
    • Updated the error logging message format for BackgroundTaskHelper.
    • Revised the explanation of BackgroundTaskHelper's role, emphasizing immediate non-blocking execution and framework-managed context lifecycle.
  • packages/skills/egg-core/references/eventbus.md
    • Added a new comprehensive reference document for EventBus, detailing common errors, usage steps (event declaration, triggering, consumption), handling multiple events, cork/uncork event buffering, and unit testing with EventWaiter.
  • packages/skills/egg/SKILL.md
    • Updated the main skill description to encompass new topics: BackgroundTaskHelper, EventBus, AOP, HTTP/MCP/Schedule controllers, and Ajv parameter validation.
    • Expanded the '核心概念' (Core Concepts) section to include EventBus and AOP.
    • Added new keywords and example queries related to EventBus and AOP for improved skill routing.
    • Updated the '协议/用例特定指示器' (Protocol/Use Case Specific Indicators) table to include 'Parameter validation', 'Background tasks', 'Event-driven / EventBus', and 'AOP / 切面编程'.
    • Added new entries to the '快速参考表' (Quick Reference Table) for 'Background tasks', 'Event-driven', 'AOP 切面编程', and 'Param validation'.
  • packages/skills/eval/evals-egg-core.json
    • Updated the description to include eventbus and aop as covered concepts.
    • Added 15 new evaluation cases (IDs 27-41) to test the AI agent's understanding and application of EventBus and AOP concepts.
  • packages/skills/eval/evals-routing.json
    • Added 3 new evaluation cases (IDs 9-11) to test the routing logic for EventBus and AOP related queries to the egg-core skill.
Activity
  • The pull request was generated using Claude Code.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@killagu killagu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.63%. Comparing base (4417c8f) to head (272df43).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #5835   +/-   ##
=======================================
  Coverage   85.62%   85.63%           
=======================================
  Files         665      665           
  Lines       13004    13004           
  Branches     1495     1495           
=======================================
+ Hits        11135    11136    +1     
+ Misses       1745     1744    -1     
  Partials      124      124           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 新增了 EventBus 和 AOP 相关的 skill 文档,并修正了现有文档中的一些技术不准确之处,整体质量很高。新增的参考文档内容详实,评估用例覆盖了关键场景。我发现了一些可以改进代码示例清晰度的小问题,请查看具体的评论。

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/skills/egg-core/SKILL.md (1)

201-212: Add language identifiers to decision tree code blocks

The decision tree blocks at lines 201-212 and 218-224 are missing language identifiers. While these are ASCII-art decision trees (not code), consider adding text or plaintext as the language identifier for consistency and to satisfy linting rules.

✨ Suggested fix for language identifiers
-```
+```text
 需要在请求之外执行任务?
 │
 ├─ 请求返回后执行,依赖当前请求上下文
-```
+```text
 需要在方法执行前后添加通用逻辑?
 │
 ├─ 针对特定方法 → `@Pointcut`(在目标方法上声明)

As per coding guidelines, the markdownlint tool flagged these blocks (MD040 rule).

Also applies to: 218-224

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/skills/egg-core/SKILL.md` around lines 201 - 212, The fenced ASCII
decision-tree blocks labeled "需要在请求之外执行任务?" and "需要在方法执行前后添加通用逻辑?" in SKILL.md
are missing language identifiers; update each triple-backtick fence to use a
neutral language tag such as ```text (or ```plaintext) so the blocks are treated
as plain text and satisfy markdownlint MD040. Locate the two code fences
containing those exact decision-tree snippets and add the language identifier to
both fences.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/skills/egg-core/SKILL.md`:
- Around line 201-212: The fenced ASCII decision-tree blocks labeled
"需要在请求之外执行任务?" and "需要在方法执行前后添加通用逻辑?" in SKILL.md are missing language
identifiers; update each triple-backtick fence to use a neutral language tag
such as ```text (or ```plaintext) so the blocks are treated as plain text and
satisfy markdownlint MD040. Locate the two code fences containing those exact
decision-tree snippets and add the language identifier to both fences.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e6cb1d09-a3f7-4552-a6ce-dc4d2320920c

📥 Commits

Reviewing files that changed from the base of the PR and between 4417c8f and 87e941c.

📒 Files selected for processing (10)
  • packages/skills/CLAUDE.md
  • packages/skills/egg-controller/SKILL.md
  • packages/skills/egg-controller/references/ajv-validate.md
  • packages/skills/egg-core/SKILL.md
  • packages/skills/egg-core/references/aop.md
  • packages/skills/egg-core/references/background-task.md
  • packages/skills/egg-core/references/eventbus.md
  • packages/skills/egg/SKILL.md
  • packages/skills/eval/evals-egg-core.json
  • packages/skills/eval/evals-routing.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the @eggjs/skills documentation set by adding new EventBus and AOP skill/reference content under egg-core, updating the egg entry skill routing/decision tree accordingly, and extending the evaluation datasets to cover the new topics.

Changes:

  • Add new egg-core reference docs for EventBus and AOP, and update egg-core/SKILL.md decision trees to route users to them.
  • Update the egg entry SKILL.md to include new routing keywords/quick tables for EventBus/AOP (and Ajv validation under controller).
  • Extend eval cases for routing and egg-core to cover EventBus/AOP scenarios; adjust some existing docs for accuracy/wording.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/skills/eval/evals-routing.json Adds routing eval prompts for EventBus/AOP queries.
packages/skills/eval/evals-egg-core.json Extends egg-core eval coverage to include eventbus + aop scenarios.
packages/skills/egg/SKILL.md Updates entry-skill routing keywords/tables to include EventBus/AOP and controller validation.
packages/skills/egg-core/SKILL.md Restructures sections and adds decision guidance for async tasks (BackgroundTaskHelper vs EventBus) and AOP.
packages/skills/egg-core/references/eventbus.md New EventBus reference guide (typing, handlers, cork/uncork, unittest waiter).
packages/skills/egg-core/references/background-task.md Corrects/clarifies BackgroundTaskHelper execution timing and logging details.
packages/skills/egg-core/references/aop.md New AOP reference guide (Advice/Pointcut/Crosscut/order/adviceParams).
packages/skills/egg-controller/references/ajv-validate.md Small doc refinements (example path + wording).
packages/skills/egg-controller/SKILL.md Expands description to include parameter validation scope.
packages/skills/CLAUDE.md Updates skill-creator references and corrects some structural naming in docs.

You can also share your feedback on Copilot code review. Take the survey.

@gxkl gxkl mentioned this pull request Mar 17, 2026
- Fix Advice default initType from Context to Singleton (matches code)
- Fix cork/uncork example to use declared event name
- Add missing OrderService import in test example
- Replace ant-skill-creator with /skill-creator in CLAUDE.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 17, 2026

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 272df43
Status: ✅  Deploy successful!
Preview URL: https://550ec661.egg-v3.pages.dev
Branch Preview URL: https://feat-skills-eventbus-aop.egg-v3.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: 272df43
Status: ✅  Deploy successful!
Preview URL: https://8f4b4ba0.egg-cci.pages.dev
Branch Preview URL: https://feat-skills-eventbus-aop.egg-cci.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/skills/egg-core/references/aop.md (2)

1-219: Consider adding an end-to-end complete example.

While the document provides good code snippets, it lacks a complete end-to-end example showing how all pieces fit together (Advice class, Service class, configuration, and potentially tests). This would help users understand the full integration pattern.

As per coding guidelines, reference documents must include end-to-end complete examples from configuration to controller to service to tests.

🔗 Suggested end-to-end example structure

Add a section showing:

## 完整示例:订单服务事务与日志

### 1. 定义 Advice(app/aspect/transaction-advice.ts)
\`\`\`typescript
// Full Advice implementation with transaction logic
\`\`\`

### 2. 应用到 Service(app/service/order-service.ts)
\`\`\`typescript
// Service with `@Pointcut` decorators
\`\`\`

### 3. Controller 调用(app/controller/order-controller.ts)
\`\`\`typescript
// HTTPController calling the service
\`\`\`

### 4. 测试(test/app/service/order-service.test.ts)
\`\`\`typescript
// Test verifying Advice behavior
\`\`\`

### 执行流程
1. Controller 接收请求
2. 调用 OrderService.createOrder
3. TransactionAdvice.beforeCall 开启事务
4. 执行业务逻辑
5. TransactionAdvice.afterReturn 提交事务
6. 返回结果
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/skills/egg-core/references/aop.md` around lines 1 - 219, Add a
complete end-to-end example section showing configuration-to-test flow: create
an Advice file (e.g. app/aspect/TransactionAdvice implementing IAdvice with
beforeCall/afterReturn/afterThrow/afterFinally), a Service (e.g.
app/service/OrderService with `@Pointcut`(TransactionAdvice) on createOrder), a
Controller (e.g. app/controller/OrderController calling
OrderService.createOrder), and a test (e.g.
test/app/service/order-service.test.ts) that asserts transaction
start/commit/rollback behavior; include any minimal config needed to load AOP,
note the important symbols (TransactionAdvice, OrderService.createOrder,
OrderController, AdviceContext methods like ctx.set/get), and add a short
execution flow steps list mapping controller → service → Advice hooks → result
so readers can follow the lifecycle.

213-219: Enhance the scenario table into a decision tree.

The current "典型场景" table is helpful but doesn't follow the required scenario-based decision tree format. Consider restructuring this section to guide users through a series of questions that lead to the appropriate AOP approach.

As per coding guidelines, reference documents must include scenario-based decision trees.

🌳 Suggested decision tree format
## 场景决策树

需要添加切面逻辑?
├─ 是否只针对特定的几个方法?
│ ├─ 是 → 使用 @Pointcut
│ │ ├─ 需要传递不同参数?→ 使用 adviceParams
│ │ └─ 需要控制执行顺序?→ 设置 order 参数
│ └─ 否 → 继续判断
│ ├─ 是否针对一类方法(如所有 Service 的写操作)?
│ │ └─ 是 → 使用 @Crosscut + NAME 模式(正则匹配)
│ ├─ 是否需要自定义匹配逻辑?
│ │ └─ 是 → 使用 @Crosscut + CUSTOM 模式
│ └─ 是否针对特定类的所有方法?
│ └─ 是 → 使用 @Crosscut + CLASS 模式
```

你的需求 推荐方案 说明
为 OrderService.createOrder 添加日志 @Pointcut(LogAdvice) 精确控制单个方法
所有 Service 的 create*/update*/delete* 方法加审计 @Crosscut(NAME) + 正则 批量匹配写操作
特定方法需要事务包裹 @Pointcut(TransactionAdvice) 使用 around 管理事务
所有 Repository 方法监控性能 @Crosscut(CUSTOM) + 回调 自定义匹配逻辑

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @packages/skills/egg-core/references/aop.md around lines 213 - 219, Replace
the existing "典型场景" table with a scenario-based decision tree titled "场景决策树"
that guides readers through questions to choose between @Pointcut and @Crosscut
variants; specifically, ask "是否只针对特定的几个方法?" → yes: use @Pointcut(Advice) and
mention adviceParams and order for parameter passing and execution order (e.g.,
LogAdvice, TransactionAdvice), otherwise continue to ask if it's a class-wide or
pattern-based match → use @Crosscut(NAME) for regex pattern matching (e.g.,
matching create*/update*/delete*), @Crosscut(CUSTOM) for custom matcher
callbacks, and @Crosscut(CLASS) for all methods on a class; after the tree, add
a compact mapping table of example needs to recommended solutions referencing
@Pointcut(LogAdvice), @Pointcut(TransactionAdvice), @Crosscut(NAME), and
@Crosscut(CUSTOM) to make choices concrete.


</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against the current code and only fix it if needed.

Inline comments:
In @packages/skills/egg-core/references/aop.md:

  • Line 15: Add a new "文件约定" section before the existing "核心概念" header that
    documents where Advice classes live and naming rules: state that Advice classes
    should be placed under app/aspect/, each Advice in its own file using kebab-case
    (e.g. log-advice.ts, transaction-advice.ts), include a short directory structure
    example showing app/aspect/ alongside app/service/, and note that Advice is
    auto-scanned by the framework (no manual registration in config required);
    reference the "核心概念" header so the new section is inserted immediately above it
    and mention "Advice" and "app/aspect" explicitly to guide readers.

Nitpick comments:
In @packages/skills/egg-core/references/aop.md:

  • Around line 1-219: Add a complete end-to-end example section showing
    configuration-to-test flow: create an Advice file (e.g.
    app/aspect/TransactionAdvice implementing IAdvice with
    beforeCall/afterReturn/afterThrow/afterFinally), a Service (e.g.
    app/service/OrderService with @Pointcut(TransactionAdvice) on createOrder), a
    Controller (e.g. app/controller/OrderController calling
    OrderService.createOrder), and a test (e.g.
    test/app/service/order-service.test.ts) that asserts transaction
    start/commit/rollback behavior; include any minimal config needed to load AOP,
    note the important symbols (TransactionAdvice, OrderService.createOrder,
    OrderController, AdviceContext methods like ctx.set/get), and add a short
    execution flow steps list mapping controller → service → Advice hooks → result
    so readers can follow the lifecycle.
  • Around line 213-219: Replace the existing "典型场景" table with a scenario-based
    decision tree titled "场景决策树" that guides readers through questions to choose
    between @Pointcut and @Crosscut variants; specifically, ask "是否只针对特定的几个方法?" →
    yes: use @Pointcut(Advice) and mention adviceParams and order for parameter
    passing and execution order (e.g., LogAdvice, TransactionAdvice), otherwise
    continue to ask if it's a class-wide or pattern-based match → use
    @Crosscut(NAME) for regex pattern matching (e.g., matching
    create*/update*/delete*), @Crosscut(CUSTOM) for custom matcher callbacks, and
    @Crosscut(CLASS) for all methods on a class; after the tree, add a compact
    mapping table of example needs to recommended solutions referencing
    @Pointcut(LogAdvice), @Pointcut(TransactionAdvice), @Crosscut(NAME), and
    @Crosscut(CUSTOM) to make choices concrete.

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: defaults

**Review profile**: CHILL

**Plan**: Pro

**Run ID**: `448907fe-29c1-44cc-ae71-8481f01e274e`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 87e941c37f87bf78e0344dc9ff41163b7e7b859d and 272df435bb30ad7d90f3852c4c9f4f5c383f3bc1.

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `packages/skills/CLAUDE.md`
* `packages/skills/egg-core/references/aop.md`
* `packages/skills/egg-core/references/eventbus.md`

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* packages/skills/egg-core/references/eventbus.md

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->


---

## 核心概念
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add file conventions section.

The document is missing a section on file conventions (directory structure, naming rules, configuration file locations). Reference documents must include guidance on where Advice classes should be placed in the project structure.

As per coding guidelines, reference documents must include file conventions.

📁 Suggested file conventions section to add

Add a section before "核心概念" covering:

## 文件约定

### 目录结构

- Advice 类建议放在 `app/aspect/` 目录
- 文件命名:kebab-case,如 `log-advice.ts`, `transaction-advice.ts`
- 每个 Advice 一个文件

示例结构:
\`\`\`
app/
├── aspect/
│   ├── log-advice.ts
│   ├── transaction-advice.ts
│   └── cache-advice.ts
├── service/
│   └── order-service.ts
\`\`\`

### 配置

Advice 会自动被框架扫描加载,无需在配置文件中注册。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/skills/egg-core/references/aop.md` at line 15, Add a new "文件约定"
section before the existing "核心概念" header that documents where Advice classes
live and naming rules: state that Advice classes should be placed under
app/aspect/, each Advice in its own file using kebab-case (e.g. log-advice.ts,
transaction-advice.ts), include a short directory structure example showing
app/aspect/ alongside app/service/, and note that Advice is auto-scanned by the
framework (no manual registration in config required); reference the "核心概念"
header so the new section is inserted immediately above it and mention "Advice"
and "app/aspect" explicitly to guide readers.

@gxkl gxkl merged commit 1980cf1 into next Mar 18, 2026
50 of 51 checks passed
@gxkl gxkl deleted the feat/skills-eventbus-aop branch March 18, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants