跳到正文
Skillpedia
写作40k · #7482

write-coding-standards-from-file

它能做什么

这个工具可以为一个项目生成编码规范文档。它会分析你提供的现有代码文件,从中归纳出项目的风格规则和指南。

适用场景

  • ✓在开始一个新项目、想定义代码风格指南时。
  • ✓当你希望团队成员都遵循相同的编码规则时。
  • ✓当你需要把项目的最佳编码实践记录下来时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/write-coding-standards-from-file/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/write-coding-standards-from-file/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请根据文件 'my_code.py' 创建一份代码风格指南。”

每周 5 个新技能,1 分钟读完。

工作原理

工具会读取你提供的代码文件,识别其中使用的编码风格(比如缩进方式和变量命名方式),然后生成一份文档,把这些规则整理出来,方便其他人遵循。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Write Coding Standards From File

Use the existing syntax of the file(s) to establish the standards and style guides for the project. If more than one file or a folder is passed, loop through each file or files in the folder, appending the file's data to temporary memory or a file, then when complete use temporary data as a single instance; as if it were the file name to base the standards and style guideline on.

Rules and Configuration

Below is a set of quasi-configuration boolean and string[] variables. Conditions for handling true, or other values for each variable are under the level two heading ## Variable and Parameter Configuration Conditions.

Parameters for the prompt have a text definition. There is one required parameter ${fileName}, and several optional parameters ${folderName}, ${instructions}, and any [configVariableAsParameter].

Configuration Variables

  • addStandardsTest = false;
  • addToREADME = false;
  • addToREADMEInsertions = ["atBegin", "middle", "beforeEnd", "bestFitUsingContext"];
    • Default to beforeEnd.
  • createNewFile = true;
  • fetchStyleURL = true;
  • findInconsistencies = true;
  • fixInconsistencies = true;
  • newFileName = ["CONTRIBUTING.md", "STYLE.md", "CODE_OF_CONDUCT.md", "CODING_STANDARDS.md", "DEVELOPING.md", "CONTRIBUTION_GUIDE.md", "GUIDELINES.md", "PROJECT_STANDARDS.md", "BEST_PRACTICES.md", "HACKING.md"];
    • For each file in ${newFileName}, if file does not exist, use that file name and break, else continue to next file name of ${newFileName}.
  • outputSpecToPrompt = false;
  • useTemplate = "verbose"; // or "v"
    • Possible values are [["v", "verbose"], ["m", "minimal"], ["b", "best fit"], ["custom"]].
    • Selects one of the two example templates at the bottom of prompt file under the level two heading ## Coding Standards Templates, or use another composition that is a better fit.
    • If custom, then apply per request.

Configuration Variables as Prompt Parameters

If any of the variable names are passed to prompt as-is, or as a similar but clearly related text value, then override the default variable value with the value passed to prompt.

Prompt Parameters

  • fileName = The name of the file that will be analyzed in terms of: indentation, variable naming, commenting, conditional procedures, functional procedures, and other syntax related data for the coding language of the file.
  • folderName = The name of the folder that will be used to extract data from multiple files into one aggregated dataset that will be analyzed in terms of: indentation, variable naming, commenting, conditional procedures, functional procedures, and other syntax related data for the coding language of the files.
  • instructions = Additional instructions, rules, and procedures that will be provided for unique cases.
  • [configVariableAsParameter] = If passed will override the default state of the configuration variable. Example:
    • useTemplate = If passed will override the configuration ${useTemplate} default. Values are [["v", "verbose"], ["m", "minimal"], ["b", "best fit"]].

Required and Optional Parameters

  • fileName - required
  • folderName - optional
  • instructions - optional
  • [configVariableAsParameter] - optional

Variable and Parameter Configuration Conditions

${fileName}.length > 1 || ${folderName} != undefined

  • If true, toggle ${fixInconsistencies} to false.

${addToREADME} == true

  • Insert the coding standards into the README.md instead of outputting to the prompt or creating a new file.
  • If true, toggle both ${createNewFile} and ${outputSpecToPrompt} to false.

${addToREADMEInsertions} == "atBegin"

  • If ${addToREADME} is true, then insert the coding standards data at the beginning of the README.md file after the title.

${addToREADMEInsertions} == "middle"

  • If ${addToREADME} is true, then insert the coding standards data at the middle of the README.md file, changing the standards title heading to match that of the README.md composition.

${addToREADMEInsertions} == "beforeEnd"

  • If ${addToREADME} is true, then insert the coding standards data at the end of the README.md file, inserting a new line after the last character, then inserting the data on a new line.

${addToREADMEInsertions} == "bestFitUsingContext"

…

常见问题

如果我提供多个文件会怎样?

如果你提供多个文件或一个文件夹,工具会综合所有文件的信息,生成一套统一的编码规范。

我可以添加自己的说明吗?

可以。你可以为特定场景添加额外说明,比如特定的命名约定或格式规则。

工具能自动修复它发现的问题吗?

可以。如果进行了相应配置,工具可以找出代码中不一致的地方,并将其修改为符合既定规范的写法。

详情

作者的原始描述

Write a coding standards document for a project using the coding styles from the file(s) and/or folder(s) passed as arguments in the prompt.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7482
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能