AGENT SKILL

refactoring-guardrails

在 super-agent-v3 中进行重构、函数拆分、抽取公共逻辑、重排文件或需要行为护栏时使用。

License 许可
Apache-2.0
最近更新
2026-10-11
Stars
★ 0
Forks
0

01 前言 Front Matter

name
refactoring-guardrails
aliases
[ "@refactoring-guardrails", "@重构护栏" ]
description
在 super-agent-v3 中进行重构、函数拆分、抽取公共逻辑、重排文件或需要行为护栏时使用。

03 SKILL.md 正文

重构护栏

基本原则

  • 重构必须保持外部行为不变;任何行为变化都要先变更需求或测试。
  • 先找受影响包、入口和测试,再改代码。
  • 涉及 Go 文件时,每改完一个文件先跑 ./scripts/test_with_guard.sh <file.go>。
  • 禁止静默兜底:双跑、影子执行或迁移对比发现差异时必须返回错误并保留 diff 证据。

推荐流程

  1. 记录重构前行为:测试、golden、快照或可执行验收脚本。
  2. 小步移动代码,保持 public contract 不变。
  3. 每个阶段运行最小验证,最后运行受影响包测试。
  4. 如果 guard 或双跑对比发现差异,停止并修复差异,不要返回旧结果继续执行。

fail-fast 对比示例

func (s *Service) calcWithGuardrail(ctx context.Context, in Input) (Output, error) {
    oldOut, oldErr := s.calcLegacy(ctx, in)
    newOut, newErr := s.calcNew(ctx, in)

    if diff := compareOutput(oldOut, newOut, oldErr, newErr); diff != nil {
        return Output{}, fmt.Errorf("guardrail diff for %s: %w", in.ID, diff)
    }
    return newOut, newErr
}

验证

  • Go:./scripts/test_with_guard.sh <affected packages> -count=1
  • guard/architecture:make guard 或 ./scripts/test_with_guard.sh ./internal/archtest -count=1
  • docs/skills-only:python3 scripts/validate_super_agent_skills.py + git diff --check

04 同仓库更多 Skills

lihah111222333-cloud
lihah111222333-cloud/Super-Dolphin-Agent-Cockpit

mcp-lsp-project-config

配置、安装、检查、修复或迁移项目级 mcp-lsp stdio MCP,覆盖 Codex、Claude Code 和 Google Antigravity,以及 Windows 原生、WSL 原生和 Windows 宿主通过 wsl.exe 桥接 Linux sidecar 的自动选型。用户提到项目 MCP、LSP MCP、.codex/config.toml、.mcp.json、.agents/mcp_config.json、Codex 中 LSP 工具有时直接暴露有时只在延迟工具目录、ALL_TOOLS 过滤为空、工具已显示但调用报 client is closing、EOF、Transport closed,或希望三个客户端共用仓库内 mcp-lsp 时使用。

Skill与智能体开发
★ 0
lihah111222333-cloud
lihah111222333-cloud/Super-Dolphin-Agent-Cockpit

注释规范

当在 super-agent-v3 中编写或审查 Go 函数级中文注释、React hooks/service/controller 注释,或处理注释守卫失败时使用。

★ 0
lihah111222333-cloud
lihah111222333-cloud/Super-Dolphin-Agent-Cockpit

字段守卫

当新增、删除、重命名或跨层传递结构化字段,以及修改 DTO、mapper、schema、API/RPC、事件、配置、store、序列化或前后端契约时自动使用;追踪生产源到全部消费端并建立 fail-fast 字段守卫。

后端与接口
★ 0
lihah111222333-cloud
lihah111222333-cloud/Super-Dolphin-Agent-Cockpit

后端

在 super-agent-v3 中编写、审查或重构 Go 后端代码时使用。

后端与接口Skill与智能体开发
★ 0
lihah111222333-cloud
lihah111222333-cloud/Super-Dolphin-Agent-Cockpit

前端

当在 super-agent-v3 中开发、审查或修复当前 React/Vite 前端 UI 时使用;前端源码只在 frontend-app。

前端开发
★ 0
lihah111222333-cloud
lihah111222333-cloud/Super-Dolphin-Agent-Cockpit

全量项目地图生成

当在 super-agent-v3 中生成、更新或校验 docs/doc/codemap 项目地图、AI index 或能力清单时使用。

★ 0