en un clic
naming
// 命名规范 / Naming conventions。在创建类、函数、变量,或重命名、检查命名时使用。核心原则:简洁优先,上下文消歧义,类型提示已提供足够信息。Use when naming classes/functions/variables, renaming code, or reviewing names. Prioritizes brevity over self-documentation.
// 命名规范 / Naming conventions。在创建类、函数、变量,或重命名、检查命名时使用。核心原则:简洁优先,上下文消歧义,类型提示已提供足够信息。Use when naming classes/functions/variables, renaming code, or reviewing names. Prioritizes brevity over self-documentation.
项目架构约定:通过 Root/Folder/File 三层极简元数据(_dir.md + I/O/Pos 注释) 让 AI 在任意位置自定位。 **AI 创建文件夹时自动触发**:hook 会生成 _dir.md 模板,AI 填写 Input/Output/Pos。
在编写、更新、维护 roadmap.md 的时候触发
多模型协作 — 调用 gemini-agent 和 codex-agent 辅助分析 **触发场景**(主动使用): - 深度代码分析:算法理解、性能瓶颈、架构梳理 - 大范围探索:5+ 文件、模块依赖、调用链追踪 - 复杂推理:方案评估、逻辑验证、并发安全分析 - 多视角决策:需要不同角度分析再综合判断 **不触发**: - 简单修改(1-2 文件的明确改动) - 文件查找(用 Explore 或 Glob/Grep) - 已知路径的读写操作 **核心原则**:你是决策者和执行者,外部模型是顾问。
代码风格规范 / Code style conventions。在编写、编辑、评审 Python 代码时使用。包括类型注解、Decimal 精度、Docstring、模块组织等规范。Use when writing, editing, or reviewing Python code. Enforces type hints, Decimal precision, docstrings, and module organization.
分层架构规范 / Architecture and layering rules (v0.3.1)。在设计新组件、修改导入、检查分层时使用。核心约束:cli → flows → data,core 向内不向外。Use when designing components, changing imports, or reviewing layering decisions. Enforces cli/flows/core/data separation.
用于梳理和可视化代码流程,生成清晰的 ASCII 流程图、数据流图和表格分析。适用于已有代码的梳理、新功能设计的说明、以及技术文档的编写。
| name | naming |
| description | 命名规范 / Naming conventions。在创建类、函数、变量,或重命名、检查命名时使用。核心原则:简洁优先,上下文消歧义,类型提示已提供足够信息。Use when naming classes/functions/variables, renaming code, or reviewing names. Prioritizes brevity over self-documentation. |
本 Skill 定义项目的命名规范,核心哲学是 上下文消歧义(Context-Aware Minimal Naming)。
在以下场景使用本 Skill(触发词:命名、取名、重命名、名字太长、naming、rename):
┌────────────────────────────────────────────────────────────┐
│ 名字只需在其出现的上下文中唯一消歧义 │
│ │
│ 模块路径 + 类型提示 + 简短名字 = 完整语义 │
└────────────────────────────────────────────────────────────┘
背景:本项目是 AI 驱动开发的独立项目,代码由开发者自己维护。类型提示、IDE 导航、AI 辅助已经提供了足够的上下文,名��不需要过度自解释。
这些是领域建模的"根",不能简化:
Trade / Fund / Nav / Dca / Action / Restriction / Policy / Config / Batch
Repo / Service / Client
模块路径已有的信息,类名不再重复。
# BAD - 模块名已经是 fund_restriction
from src.core.models.fund_restriction import FundRestrictionFact
# GOOD
from src.core.models.fund_restriction import Restriction
from src.core.models.fund_restriction import Fact
# BAD - 模块名已经是 dca_backfill
class DcaDayCheck: ...
class FundDcaFacts: ...
# GOOD
class DayCheck: ...
class Facts: ... # 或 DcaFacts(保留一级前缀)
后缀仅在需要区分时使用:
| 后缀 | 含义 | 何时使用 |
|---|---|---|
Result | 函数返回的聚合结果 | 需要区分动词和名词时 |
Facts | 规则层只读快照 | AI 分析场景 |
Draft | 待确认的建议方案 | 不入库的中间结构 |
Check | 检查/验证结果 | 规则层输出 |
Flag | 标记/警告 | 异常标识 |
简化示例:
# BAD
class BackfillDaysResult: ...
# GOOD
class BackfillResult: ...
类型提示已说明类型,变量名只需说明角色。
# BAD
def foo(trade_repo: TradeRepo, fund_code: str, trade_date: date): ...
# GOOD
def foo(repo: TradeRepo, code: str, day: date): ...
常用简化映射:
| 冗余写法 | 简化写法 | 说明 |
|---|---|---|
fund_code | code | 基金上下文已知 |
trade_date | day / on | 类型已知是 date |
trade_repo | repo | 类型已知是 TradeRepo |
dca_plan_key | dca_key / key | 上下文已知 |
confirmation_status | state | 简单词优先 |
delayed_reason | delay_reason | 去掉 ed |
动词(必需) + 对象(仅当上下文不明确时)
# BAD - 过度描述
def build_dca_facts_for_batch(): ...
def get_dca_day_checks(): ...
def update_dca_plan_key_bulk(): ...
# GOOD - 动词 + 最小限定
def build_facts(): ... # batch_id 是参数,不需要在函数名里
def day_checks(): ... # 或 checks()
def tag_dca(): ... # 或 set_keys()
dca_backfill 模块(典型冗余案例):
# 现有
class DcaDayCheck: ...
class BackfillDaysResult: ...
class FundDcaFacts: ...
class SkippedTrade: ...
def build_dca_facts_for_batch(): ...
def get_dca_day_checks(): ...
# 建议
class DayCheck: ... # 模块已知是 dca
class BackfillResult: ... # 简化
class Facts: ... # 或 DcaFacts
class Skipped: ... # 上下文已知是 trade
def build_facts(): ... # batch_id 是参数
def checks(): ... # 或 day_checks()
# 现有
@dataclass
class Trade:
confirmation_status: str
delayed_reason: str | None
delayed_since: date | None
dca_plan_key: str | None
import_batch_id: int | None
# 建议
@dataclass
class Trade:
state: str # 或 confirm_state
delay_reason: str | None
delay_since: date | None
dca_key: str | None
batch_id: int | None # import 上下文已知
跨模块导出:如果类会被多个模块 import,保留前缀避免歧义
# 在 __init__.py 导出时保留完整名
from .dca_backfill import DcaFacts # 不是 Facts
领域核心模型:Trade, Fund, Nav 等不简化
容易混淆的场景:如果简化后有歧义,保留
命名规范是 code-style 的子集,但更专注、更激进。