Standards Extraction Skill
从项目配置文件中提取编码标准、格式化规则和贡献指南。返回关于项目约定的结构化数据。
变量
| 变量 | 默认 | 描述 |
|---|---|---|
| INCLUDE_LINTER_RULES | true | 解析ESLint、Prettier、Ruff配置 |
| INCLUDE_EDITOR_CONFIG | true | 解析.editorconfig |
| INCLUDE_GIT_HOOKS | true | 检查pre-commit、husky配置 |
| OUTPUT_FORMAT | json | 输出格式:json、markdown或toon |
指令
MANDATORY - 按照以下工作流程步骤进行。不要跳过步骤。
- 检查CONTRIBUTING.md或类似的指南文件
- 解析格式化配置文件
- 解析linting配置文件
- 检查git hooks和CI检查
- 编译标准摘要
红旗 - 停止并重新考虑
如果你即将:
- 在不检查配置文件的情况下假设格式化规则
- 因为“它可能是标准”而跳过CONTRIBUTING.md
- 没有证据从配置文件中推断约定
- 报告与实际配置文件相矛盾的规则
停止 -> 阅读配置文件 -> 提取实际规则 -> 然后报告
工作流程
1. 发现标准文件
按顺序检查这些文件:
| 文件 | 类型 | 目的 |
|---|---|---|
CONTRIBUTING.md |
Markdown | 贡献指南 |
CONTRIBUTING |
文本 | 贡献指南 |
docs/CONTRIBUTING.md |
Markdown | 贡献指南 |
.github/CONTRIBUTING.md |
Markdown | 贡献指南 |
.editorconfig |
INI | 编辑器格式化 |
.prettierrc* |
JSON/YAML | Prettier配置 |
prettier.config.* |
JS/TS | Prettier配置 |
.eslintrc* |
JSON/YAML | ESLint配置 |
eslint.config.* |
JS/TS | ESLint平面配置 |
pyproject.toml |
TOML | Python工具(ruff, black, isort) |
.ruff.toml |
TOML | Ruff配置 |
.pre-commit-config.yaml |
YAML | Pre-commit钩子 |
.husky/ |
目录 | Git钩子 |
.github/PULL_REQUEST_TEMPLATE.md |
Markdown | PR模板 |
.github/ISSUE_TEMPLATE/ |
目录 | 问题模板 |
2. 提取贡献指南
从CONTRIBUTING.md中提取:
- 提交信息格式:Conventional commits, gitmoji等。
- 分支命名:feature/, fix/等。
- PR流程:需要的审核者,检查等。
- 代码风格说明:任何明确的指导
- 测试要求:需要什么测试
3. 提取格式化规则
从.editorconfig中:
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
从Prettier配置中:
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"printWidth": 100
}
4. 提取Linting规则
从ESLint中:
- 关键启用/禁用规则
- 扩展配置(airbnb, standard等。)
- 自定义规则
从Ruff/Black(pyproject.toml)中:
[tool.ruff]
line-length = 88
select = ["E", "F", "I"]
[tool.black]
line-length = 88
5. 提取Git钩子
从.pre-commit-config.yaml中:
- 提交时运行的钩子
- 需要的检查
从.husky/中:
- pre-commit脚本
- pre-push脚本
6. 编译输出
{
"project_root": "/path/to/project",
"extracted_at": "2025-12-21T12:00:00Z",
"contribution_guidelines": {
"source": "CONTRIBUTING.md",
"commit_format": "conventional",
"branch_naming": "type/description",
"pr_requirements": ["tests", "review"],
"notes": []
},
"formatting": {
"indent_style": "space",
"indent_size": 2,
"line_length": 100,
"quotes": "single",
"semicolons": true,
"trailing_commas": "es5",
"sources": [".editorconfig", ".prettierrc"]
},
"linting": {
"javascript": {
"tool": "eslint",
"extends": ["next/core-web-vitals"],
"key_rules": {}
},
"python": {
"tool": "ruff",
"line_length": 88,
"select": ["E", "F", "I"]
}
},
"git_hooks": {
"pre_commit": ["lint-staged", "prettier"],
"pre_push": ["test"]
},
"ci_checks": {
"source": ".github/workflows/",
"checks": ["lint", "test", "build"]
}
}
Cookbook
解析配置
- IF: 需要解析任何配置文件
- THEN: 阅读并执行
./cookbook/config-parsing.md
快速参考
提交格式检测
| CONTRIBUTING.md中的模式 | 格式 |
|---|---|
| “Conventional Commits” | conventional |
| “feat:”, “fix:”, “chore:” | conventional |
| ":emoji:"或gitmoji | gitmoji |
| "JIRA-123"模式 | jira |
| 未发现模式 | freeform |
常见格式化器配置
| 文件 | 工具 |
|---|---|
.prettierrc* |
Prettier |
biome.json |
Biome |
.editorconfig |
EditorConfig |
dprint.json |
dprint |
常见Linting配置
| 文件 | 工具 |
|---|---|
.eslintrc*, eslint.config.* |
ESLint |
pyproject.toml [tool.ruff] |
Ruff |
pyproject.toml [tool.pylint] |
Pylint |
.golangci.yml |
golangci-lint |
clippy.toml |
Clippy (Rust) |
输出模式
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"project_root": {"type": "string"},
"extracted_at": {"type": "string", "format": "date-time"},
"contribution_guidelines": {
"type": "object",
"properties": {
"source": {"type": "string"},
"commit_format": {"type": "string"},
"branch_naming": {"type": "string"},
"pr_requirements": {"type": "array", "items": {"type": "string"}},
"notes": {"type": "array", "items": {"type": "string"}}
}
},
"formatting": {
"type": "object",
"properties": {
"indent_style": {"type": "string"},
"indent_size": {"type": "integer"},
"line_length": {"type": "integer"},
"quotes": {"type": "string"},
"semicolons": {"type": "boolean"},
"sources": {"type": "array", "items": {"type": "string"}}
}
},
"linting": {"type": "object"},
"git_hooks": {"type": "object"},
"ci_checks": {"type": "object"}
}
}
集成
此技能由以下使用:
/ai-dev-kit:quickstart-codebase- 入职工作流程lane-executor- 遵循项目约定- 贡献验证 - 检查PR合规性