mcpField
A
architectural-decisions

architectural-decisions

github.com/repowise-dev开发8.0k93 次安装今天更新
代码仓库

关于 architectural-decisions

architectural-decisions 是 Repowise 的技能,用于查找和记录代码架构背后的决策依据。它检索决策记录与源代码历史,并展示决策健康状况和缺少治理的区域。

主要功能

  1. 01按查询或文件搜索决策
  2. 02将理由追溯至源证据
  3. 03检查决策状态与治理缺口
  4. 04记录并审核候选决策

适用场景

  1. 01查询代码区域采用某设计的原因
  2. 02架构变更前检查既有决策
  3. 03发现过时决策或缺少治理的区域
  4. 04记录并确认架构选择

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/repowise-dev/repowise --skill architectural-decisions

安装后在 Claude Code 中输入/architectural-decisions确认已加载。

详细介绍

使用 Repowise 做出架构决策

Repowise 会记录架构决策——也就是代码为何以这种方式构建。

get_why 有四种模式,根据你传入的参数选择:

  1. get_why(query="why is auth using JWT?") — 按关键词和语义搜索决策。
  2. get_why(query="src/auth/service.py") — 查找影响该文件的决策,以及该文件的由来和一致性评分(该文件是否仍遵循自己的 ADR?)。
  3. get_why(query="why was caching added?", targets=["src/auth/cache.py"]) — 以目标为锚点进行搜索;会提高涉及这些目标的决策的优先级。
  4. get_why() — 查看决策健康状况仪表板。

决策从五种来源中挖掘而来(ADR 文件、PR 和 squash commit 正文、内联标记、Git 考古,以及按中心性限定范围的代码注释)。每条决策依据都能追溯到原文片段,并标记为 exact / fuzzy / unverified。如果某个路径没有相关决策,get_why 会回退到 Git 考古,因此调用结果不会为空。

当用户询问“X 为什么这样构建?”

调用 get_why(query="X")。

即将进行架构变更时

  1. 调用 get_why(query="你要修改的具体区域"),查找影响该区域的现有决策。
  2. 如果找到决策,继续之前先向用户说明——他们可能不希望与现有架构选择相矛盾。
  3. 如果没有找到决策,继续操作,但要说明该区域没有受任何已记录决策约束。

未指定具体查询时

不带参数调用 get_why(),查看决策健康状况仪表板:

  • 可能已不再适用的过时决策
  • 等待确认的拟议决策
  • 未受决策约束的热点区域(变更频繁但没有已记录决策的文件)

CLI 中也可以通过 repowise decision health / /repowise:decision 查看相同信号;你也可以在任务进行中通过 repowise why / /repowise:why 查询 原因(即 get_why 适配器)。repowise decision candidates --format json 会列出拟议决策及每项仍需满足的条件;repowise decision confirm <id> 可接受一项决策(参见 /repowise:decision)。

文件包含决策标记时

如果你在代码中看到 # WHY:、# DECISION:、# TRADEOFF: 或 # ADR: 注释,请调用 get_context(targets=["that_file.py"]),查看包含上下文和受影响模块的完整决策记录。

记录新决策

当你自己确定了一项架构选择(权衡选项后选定其中一项)时,请记录下来:

repowise decision add --agent <your slug> --title "..." --decision "..." --rationale "<why, and what you rejected>" --affects <path>

提交后,添加 --evidence-commit <sha>。记录会作为候选项保存:只有被接受后才会生效,因此记录操作是安全的。

审核候选项

你可以自行审核并接受候选项。repowise decision candidates --format json 会列出每项候选决策及其 blockers。使用 repowise decision confirm <id> --agent <your slug> 接受一项决策,并根据阻碍项的要求添加 --reason、--scope <path>、--evidence <commit|file|link> 或 --decision。使用 repowise decision dismiss <id> --agent <your slug> --reason ... --yes 驳回错误的候选项;使用 repowise decision merge <id> <into-id> --agent <your slug> 合并重复项(目标必须已被接受;请先确认目标);使用 repowise decision deprecate <id> --agent <your slug> --reason ... 弃用一项决策。当已接受的决策处于 needs_review 状态且仍然成立时,使用 repowise decision reaffirm <id> --agent <your slug> 续期;confirm 仅适用于候选项。使用 --format json 时,每个审核命令都会返回 results[],即使只有一个 id 也是如此。你的接受操作会记录在你名下,而不会记在某个人名下。如果仓库关闭了 Agent 接受功能,系统会拒绝确认操作;请将其留给他人处理并说明情况。

如果用户提出了一项决策,可以主动提出按相同方式记录,但不添加 --agent。

评论

支持 Markdown