xiaohongshu
xiaohongshu
go-import-enforcer
Go 包导入规范检查与修复工具。基于 Claude 智能分析的 Go 项目导入规范检查工具,全面扫描和分析项目代码,识别真正的规范问题,提供准确的分析报告和修复建议。
Full skill instructions
基于 Claude 智能分析的 Go 项目导入规范检查工具,通过大模型全面扫描和分析项目代码,识别真正的规范问题,提供准确的分析报告和修复建议。
核心特点:
工作原理:
核心定位:100% Claude(智能分析、报告生成、内容调整)
# 直接将整个项目交给 Claude 进行全面分析
# Claude 会自动:
# 1. 扫描所有 Go 文件
# 2. 分析导入规范问题
# 3. 检测循环依赖
# 4. 提供修复建议和最佳实践
# 5. 自动调整不规范内容
重要提示:本技能完全由 Claude 主导,无需任何脚本辅助。
目标:全面分析项目导入规范情况
时间:3-5 分钟(取决于代码量)
Claude 分析流程:
开始
↓
1. Claude 智能扫描
├─ 扫描所有 Go 文件(手写代码 + 生成代码)
├─ 分析导入格式规范
├─ 验证四段分组规则
├─ 检查别名使用规范
├─ 检测循环依赖
├─ 评估代码质量
├─ 识别误报和实际问题
├─ 提供修复建议和最佳实践
└─ 生成详细分析报告
↓
2. Claude 自动调整
├─ 格式化导入语句
├─ 调整分组和排序
├─ 应用正确别名
└─ 解决循环依赖(如果需要)
↓
完成(输出规范化代码 + 完整报告)
核心能力:
*.pb.go, wire_gen.go 等三项强制规则:
import 语句必须使用 () 包裹错误示例:
// ❌ 错误:未使用括号包裹
import "context"
import "fmt"
// ❌ 错误:未分段,未排序
import (
"github.com/go-kratos/kratos/v2/errors"
"context"
kitlog "github.com/fsyyft-go/kit/log"
"fmt"
)
// ❌ 错误:fsyyft-go 包未取别名
import (
"github.com/fsyyft-go/kit/log"
)
正确示例:
// ✅ 正确格式
import (
"context"
"fmt"
"strings"
"time"
"github.com/gin-gonic/gin"
"github.com/go-kratos/kratos/v2/errors"
kratoshttp "github.com/go-kratos/kratos/v2/transport/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
kitlog "github.com/fsyyft-go/kit/log"
kitruntime "github.com/fsyyft-go/kit/runtime"
apphelloworldv1 "github.com/fsyyft-go/kratos-layout/api/helloworld/v1"
appconf "github.com/fsyyft-go/kratos-layout/internal/pkg/conf"
)
| 段落 | 内容 | 别名要求 | 示例 |
|---|---|---|---|
| 第一段 | Go 标准库 | 无需别名 | context, fmt, strings, time |
| 第二段 | 第三方包(github.com 等) | 建议取别名 | kratoshttp "github.com/go-kratos/..." |
| 第三段 | fsyyft-go 相关包 | 强制使用 kit 前缀别名 | kitlog "github.com/fsyyft-go/kit/log" |
| 第四段 | 项目内部包 | 强制使用 app 前缀别名 | appconf "github.com/.../internal/pkg/conf" |
fsyyft-go 包别名:
| 包路径 | 强制别名 |
|---|---|
github.com/fsyyft-go/kit/log | kitlog |
github.com/fsyyft-go/kit/runtime | kitruntime |
github.com/fsyyft-go/kit/kratos/middleware/validate | kitkratosmiddlewarevalidate |
项目内部包别名:
| 包路径 | 强制别名 |
|---|---|
github.com/fsyyft-go/kratos-layout/api/helloworld/v1 | apphelloworldv1 |
github.com/fsyyft-go/kratos-layout/internal/pkg/conf | appconf |
github.com/fsyyft-go/kratos-layout/internal/pkg/log | applog |
症状:
Claude 分析需要较长时间
解决方案:
症状:
生成文件被意外修改
解决方案:
*.pb.go, wire_gen.go)触发条件:
回滚方法:
# 使用 Git 回滚
git checkout .
# 或恢复备份
git reset --hard HEAD~
确保代码可编译
go build ./...创建分支
提交更改
Claude 全面分析
审查调整结果
验证修复
go build ./...go test ./...查看分析报告
提交更改
代码审查
第一步:Claude 扫描
第二步:Claude 分析
第三步:Claude 调整
最终结果
100% Claude 驱动
区分代码类型
*.pb.go, wire_gen.go)Claude 自动调整
性能考虑
references/import_standards.md - 提取的导入规范references/alias_mapping.md - 标准别名映射表internal/biz/greeter.go - 业务层示例internal/service/greeter.go - 服务层示例cmd/web/main.go - 应用入口示例xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience