Write coding standards from file
Analyze one file or a folder of files, infer the majority syntax and style conventions, optionally compare them with language style references, and output or write a project coding standards document.
When to invoke
- "Create coding standards from this file."
- "Infer our style guide from this folder."
- "Write CODING_STANDARDS.md based on these examples."
- "Add project coding standards to README.md."
- "Find and fix inconsistencies while generating the guide."
Inputs
Use $ARGUMENTS to resolve the required fileName, optional folderName, optional instructions, and any configuration override passed as [configVariableAsParameter]. If multiple files or folderName are supplied, aggregate their style observations into one temporary dataset before writing standards.
| Parameter |
Required |
Meaning |
fileName |
Yes |
File analyzed for indentation, variable naming, commenting, conditional procedures, functional procedures, and syntax style. |
folderName |
No |
Folder whose files are aggregated and analyzed as one dataset. |
instructions |
No |
Extra rules, procedures, or unique-case guidance. |
[configVariableAsParameter] |
No |
Override a default such as useTemplate, addToREADME, createNewFile, or newFileName. |
Configuration variables
| Variable |
Default |
Rule |
addStandardsTest |
false |
When true, write a test file that checks whether the analyzed files adhere to the generated standards. |
addToREADME |
false |
When true, insert standards into README.md and set createNewFile=false, outputSpecToPrompt=false. |
addToREADMEInsertions |
["atBegin", "middle", "beforeEnd", "bestFitUsingContext"] |
Default to beforeEnd; controls where standards are inserted in README.md. |
createNewFile |
true |
Create a standards file and set outputSpecToPrompt=false, addToREADME=false. |
fetchStyleURL |
true |
Fetch the relevant language style URL from the reference list when a language can be identified. |
findInconsistencies |
true |
Count indentation, line-break, comment, conditional/function nesting, and quote-wrapper patterns; record minority deviations. |
fixInconsistencies |
true |
Edit low-count categories to match the majority when safe; set to false when more than one file or folderName is used. |
newFileName |
candidate list |
Use the first missing name from 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. |
outputSpecToPrompt |
false |
Return standards in the response and set createNewFile=false, addToREADME=false. |
useTemplate |
"verbose" or "v" |
Accept [ ["v", "verbose"], ["m", "minimal"], ["b", "best fit"], ["custom"] ]; custom uses the supplied instructions or template. |
Decision rules
| Condition |
Action |
| `${fileName}.length > 1 |
|
${addToREADME} == true |
Insert into README.md; disable createNewFile and outputSpecToPrompt. |
${addToREADMEInsertions} == "atBegin" |
Insert after the title in README.md. |
${addToREADMEInsertions} == "middle" |
Insert near the middle and adapt the standards heading to the README composition. |
${addToREADMEInsertions} == "beforeEnd" |
Insert at the end after a new line. |
${addToREADMEInsertions} == "bestFitUsingContext" |
Insert at the best fitting line based on README context and flow. |
${addStandardsTest} == true |
Write a standards adherence test after the standards file is complete. |
${createNewFile} == true |
Create a file from newFileName; disable README insertion and prompt-only output. |
${fetchStyleURL} == true |
For the detected language, fetch the relevant URL from ### Fetch Links style references. |
${findInconsistencies} == true |
Categorize syntax patterns, count majority/minority forms, and store inconsistencies. |
${fixInconsistencies} == true |
Fix minority syntax categories using stored inconsistency evidence. |
typeof ${newFileName} == "string" |
Create exactly that file. |
typeof ${newFileName} != "string" |
Iterate the candidate list and use the first file that does not exist, then break. |
${outputSpecToPrompt} == true |
Return the standards instead of writing a file or README update. |
| `${useTemplate} == "v" |
|
| `${useTemplate} == "m" |
|
| `${useTemplate} == "b" |
|
| `${useTemplate} == "custom" |
|
Compatibility tokens
Keep these original configuration labels recognizable when translating older requests: boolean, string[], string, object, quasi-configuration, as-is, and/or, or, top-level, well-known, line-breaks, ${fileName}, ${folderName}, ${instructions}, ${addToREADME}, ${createNewFile}, ${fixInconsistencies}, ${newFileName}, ${outputSpecToPrompt}, ${useTemplate}, ${fileName} == [<Language> Style Guide], #fetch ${item}, and #fetch (URL). The template selectors may appear as [ ["v", "verbose"], ["m", "minimal"], ["b", "best fit"] ], [["v", "verbose"], ["m", "minimal"], ["b", "best fit"]], "m", "minimal", "v", verbose", ### "m", "minimal", ### "v", "verbose", ## Coding Standards Templates, and ## Variable and Parameter Configuration Conditions in source material.
When demonstrating spacing or braces, include examples such as if (x), not if(x), and sample calls like do_something and do_something_else only as illustrative placeholders.
Standards content
| Section |
Infer from source |
| Introduction |
Purpose, scope, language, package, and project context. |
| Naming conventions |
Variables such as camelCase or lower_snake_case, functions/methods, classes/structs, constants like UPPER_SNAKE_CASE, and file naming. |
| Formatting and style |
Indentation, line length, braces such as K&R or Allman, blank lines, UTF-8/no BOM, final newline. |
| Comments and documentation |
Docstrings, inline comments, file headers, TODO, FIXME, and NOTE practices. |
| Error handling |
Exception types, returned errors, logging expectations, cleanup requirements. |
| Best practices and anti-patterns |
Global variables, magic numbers, repetition, unused code, and language-specific rules. |
| Examples |
One correct and one corrected bad example when useful. |
| Contribution and enforcement |
Code review expectations, tests, and guide maintenance. |
Style reference map
When fetchStyleURL is true, use only the relevant language or ecosystem links:
| Language or ecosystem |
URL |
| C Style Guide |
https://users.ece.cmu.edu/~eno/coding/CCodingStandard.html |
| C# Style Guide |
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions |
| C++ Style Guide |
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines |
| Go Style Guide |
https://github.com/golang-standards/project-layout |
| Java Style Guide |
https://coderanch.com/wiki/718799/Style |
| AngularJS App Style Guide |
https://github.com/mgechev/angularjs-style-guide |
| jQuery Style Guide |
https://contribute.jquery.org/style-guide/js/ |
| JavaScript Style Guide |
https://www.w3schools.com/js/js_conventions.asp |
| JSON Style Guide |
https://google.github.io/styleguide/jsoncstyleguide.xml |
| Kotlin Style Guide |
https://kotlinlang.org/docs/coding-conventions.html |
| Markdown Style Guide |
https://cirosantilli.com/markdown-style-guide/ |
| Perl Style Guide |
https://perldoc.perl.org/perlstyle |
| PHP Style Guide |
https://phptherightway.com/ |
| Python Style Guide |
https://peps.python.org/pep-0008/ |
| Ruby Style Guide |
https://rubystyle.guide/ |
| Rust Style Guide |
https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide/src |
| Swift Style Guide |
https://www.swift.org/documentation/api-design-guidelines/ |
| TypeScript Style Guide |
https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html |
| Visual Basic Style Guide |
https://en.wikibooks.org/wiki/Visual_Basic/Coding_Standards |
| Shell Script Style Guide |
https://google.github.io/styleguide/shellguide.html |
| Git Usage Style Guide |
https://github.com/agis/git-style-guide |
| PowerShell Style Guide |
https://github.com/PoshCode/PowerShellPracticeAndStyle |
| CSS |
https://cssguidelin.es/ |
| Sass Style Guide |
https://sass-guidelin.es/ |
| HTML Style Guide |
https://github.com/marcobiedermann/html-style-guide |
| Linux kernel Style Guide |
https://www.kernel.org/doc/html/latest/process/coding-style.html |
| Node.js Style Guide |
https://github.com/felixge/node-style-guide |
| SQL Style Guide |
https://www.sqlstyle.guide/ |
| Angular Style Guide |
https://angular.dev/style-guide |
| Vue Style Guide |
https://vuejs.org/style-guide/rules-strongly-recommended.html |
| Django Style Guide |
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/ |
| SystemVerilog Style Guide |
https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md |
Examples
Minimal template
Use for small projects or when useTemplate is "m" or "minimal".
## 1. Introduction
* **Purpose:** Briefly explain why the coding standards are being established.
* **Scope:** Define which languages, projects, or modules this specification applies to.
## 2. Naming Conventions
* **Variables:** `camelCase`
* **Functions/Methods:** `PascalCase` or `camelCase`.
* **Classes/Structs:** `PascalCase`.
* **Constants:** `UPPER_SNAKE_CASE`.
## 3. Formatting and Style
* **Indentation:** Use 4 spaces per indent or tabs.
* **Line Length:** Limit lines to a maximum of 80 or 120 characters.
* **Braces:** Use K&R or Allman style.
* **Blank Lines:** Specify separation between logical blocks.
## 4. Commenting
* **Docstrings/Function Comments:** Describe purpose, parameters, and return values.
* **Inline Comments:** Explain complex or non-obvious logic.
* **File Headers:** Specify author, date, and file description if the project uses them.
## 5. Error Handling
* **General:** How to handle and log errors.
* **Specifics:** Which exception types to use and what to include in error messages.
## 6. Best Practices and Anti-Patterns
* **General:** Avoid global variables and magic numbers.
* **Language-specific:** Add project-specific recommendations.
## 7. Examples
* Provide correct and incorrect examples.
## 8. Contribution and Enforcement
* Explain review and enforcement.
Verbose template
Use for larger projects, or when useTemplate is "v" or "verbose".
# Style Guide
This document defines the style and conventions used in this project.
All contributions should follow these rules unless otherwise noted.
## 1. General Code Style
- Favor clarity over brevity.
- Keep functions and methods small and focused.
- Avoid repeating logic; prefer shared helpers/utilities.
- Remove unused variables, imports, code paths, and files.
## 2. Naming Conventions
| Item | Convention | Example |
| --- | --- | --- |
| Variables | `lower_snake_case` | `buffer_size` |
| Functions | `lower_snake_case()` | `read_file()` |
| Constants | `UPPER_SNAKE_CASE` | `MAX_RETRIES` |
| Types/Structs | `PascalCase` | `FileHeader` |
| File Names | `lower_snake_case` | `file_reader.c` |
## 3. Formatting Rules
- Indentation: **4 spaces**
- Line length: **max 100 characters**
- Encoding: **UTF-8**, no BOM
- End files with a newline
## 4. Comments & Documentation
- Explain why, not what, unless intent is unclear.
- Keep comments up-to-date as code changes.
- Public functions should include a short description of purpose and parameters.
- Tags: `TODO: follow-up work`, `FIXME: known incorrect behavior`, `NOTE: non-obvious design decision`.
## 5. Error Handling
- Handle error conditions explicitly.
- Avoid silent failures.
- Clean up resources before returning on failure.
## 6. Commit & Review Practices
- One logical change per commit.
- Write clear commit messages.
- Keep pull requests reasonably small.
## 7. Tests
- Write tests for new functionality.
- Tests should be deterministic.
- Prefer readable test cases over complex test abstraction.
## 8. Changes to This Guide
Style evolves. Propose improvements by updating this document.
Output template
## Coding standards result
**Status:** created file | updated README.md | output only | blocked
**Source:** `<fileName or folderName>`
**Template:** minimal | verbose | best fit | custom
### Style evidence
| Category | Majority pattern | Exceptions |
| --- | --- | --- |
| Indentation | <tabs/2/4 spaces> | <files or none> |
| Naming | <observed conventions> | <exceptions or none> |
| Comments | <docstring/comment style> | <exceptions or none> |
| Error handling | <observed approach> | <exceptions or none> |
### Artifact
- `<CONTRIBUTING.md or STYLE.md or CODE_OF_CONDUCT.md or CODING_STANDARDS.md or DEVELOPING.md or CONTRIBUTION_GUIDE.md or GUIDELINES.md or PROJECT_STANDARDS.md or BEST_PRACTICES.md or HACKING.md or README.md>`
### Inconsistencies
- <fixed or reported inconsistency>
### Validation
- `fetchStyleURL`: true | false, <URL or not applicable>
- `findInconsistencies`: true | false
- `fixInconsistencies`: true | false
Quality gate
References
1---2name: write-coding-standards-from-file3description: Write a coding standards document by analyzing existing file or folder style. Use when asked to infer project rules, generate CONTRIBUTING.md or CODING_STANDARDS.md, add standards to README.md, find or fix style inconsistencies, choose a minimal or verbose template, or fetch language style references.4---56<!-- Generated from harness/github-copilot/skills/write-coding-standards-from-file/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# Write coding standards from file910Analyze one file or a folder of files, infer the majority syntax and style conventions, optionally compare them with language style references, and output or write a project coding standards document.1112## When to invoke1314- "Create coding standards from this file."15- "Infer our style guide from this folder."16- "Write CODING_STANDARDS.md based on these examples."17- "Add project coding standards to README.md."18- "Find and fix inconsistencies while generating the guide."1920## Inputs2122Use `$ARGUMENTS` to resolve the required `fileName`, optional `folderName`, optional `instructions`, and any configuration override passed as `[configVariableAsParameter]`. If multiple files or `folderName` are supplied, aggregate their style observations into one temporary dataset before writing standards.2324| Parameter | Required | Meaning |25| --- | --- | --- |26| `fileName` | Yes | File analyzed for indentation, variable naming, commenting, conditional procedures, functional procedures, and syntax style. |27| `folderName` | No | Folder whose files are aggregated and analyzed as one dataset. |28| `instructions` | No | Extra rules, procedures, or unique-case guidance. |29| `[configVariableAsParameter]` | No | Override a default such as `useTemplate`, `addToREADME`, `createNewFile`, or `newFileName`. |3031## Configuration variables3233| Variable | Default | Rule |34| --- | --- | --- |35| `addStandardsTest` | `false` | When true, write a test file that checks whether the analyzed files adhere to the generated standards. |36| `addToREADME` | `false` | When true, insert standards into `README.md` and set `createNewFile=false`, `outputSpecToPrompt=false`. |37| `addToREADMEInsertions` | `["atBegin", "middle", "beforeEnd", "bestFitUsingContext"]` | Default to `beforeEnd`; controls where standards are inserted in `README.md`. |38| `createNewFile` | `true` | Create a standards file and set `outputSpecToPrompt=false`, `addToREADME=false`. |39| `fetchStyleURL` | `true` | Fetch the relevant language style URL from the reference list when a language can be identified. |40| `findInconsistencies` | `true` | Count indentation, line-break, comment, conditional/function nesting, and quote-wrapper patterns; record minority deviations. |41| `fixInconsistencies` | `true` | Edit low-count categories to match the majority when safe; set to `false` when more than one file or `folderName` is used. |42| `newFileName` | candidate list | Use the first missing name from `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`. |43| `outputSpecToPrompt` | `false` | Return standards in the response and set `createNewFile=false`, `addToREADME=false`. |44| `useTemplate` | `"verbose"` or `"v"` | Accept `[ ["v", "verbose"], ["m", "minimal"], ["b", "best fit"], ["custom"] ]`; `custom` uses the supplied instructions or template. |4546## Decision rules4748| Condition | Action |49| --- | --- |50| `${fileName}.length > 1 || ${folderName} != undefined` | Toggle `fixInconsistencies` to `false`. |51| `${addToREADME} == true` | Insert into `README.md`; disable `createNewFile` and `outputSpecToPrompt`. |52| `${addToREADMEInsertions} == "atBegin"` | Insert after the title in `README.md`. |53| `${addToREADMEInsertions} == "middle"` | Insert near the middle and adapt the standards heading to the README composition. |54| `${addToREADMEInsertions} == "beforeEnd"` | Insert at the end after a new line. |55| `${addToREADMEInsertions} == "bestFitUsingContext"` | Insert at the best fitting line based on README context and flow. |56| `${addStandardsTest} == true` | Write a standards adherence test after the standards file is complete. |57| `${createNewFile} == true` | Create a file from `newFileName`; disable README insertion and prompt-only output. |58| `${fetchStyleURL} == true` | For the detected language, fetch the relevant URL from `### Fetch Links` style references. |59| `${findInconsistencies} == true` | Categorize syntax patterns, count majority/minority forms, and store inconsistencies. |60| `${fixInconsistencies} == true` | Fix minority syntax categories using stored inconsistency evidence. |61| `typeof ${newFileName} == "string"` | Create exactly that file. |62| `typeof ${newFileName} != "string"` | Iterate the candidate list and use the first file that does not exist, then `break`. |63| `${outputSpecToPrompt} == true` | Return the standards instead of writing a file or README update. |64| `${useTemplate} == "v" || ${useTemplate} == "verbose"` | Use the verbose template. |65| `${useTemplate} == "m" || ${useTemplate} == "minimal"` | Use the minimal template. |66| `${useTemplate} == "b" || ${useTemplate} == "best"` | Pick the minimal or verbose template based on observed project complexity. |67| `${useTemplate} == "custom" || ${useTemplate} == "<ANY_NAME>"` | Use the custom prompt, instructions, template, or data supplied by the user. |686970## Compatibility tokens7172Keep these original configuration labels recognizable when translating older requests: `boolean`, `string[]`, `string`, `object`, `quasi-configuration`, `as-is`, `and/or`, ` or `, `top-level`, `well-known`, `line-breaks`, `${fileName}`, `${folderName}`, `${instructions}`, `${addToREADME}`, `${createNewFile}`, `${fixInconsistencies}`, `${newFileName}`, `${outputSpecToPrompt}`, `${useTemplate}`, `${fileName} == [<Language> Style Guide]`, `#fetch ${item}`, and `#fetch (URL)`. The template selectors may appear as `[ ["v", "verbose"], ["m", "minimal"], ["b", "best fit"] ]`, `[["v", "verbose"], ["m", "minimal"], ["b", "best fit"]]`, `"m", "minimal"`, `"v", verbose"`, `### "m", "minimal"`, `### "v", "verbose"`, `## Coding Standards Templates`, and `## Variable and Parameter Configuration Conditions` in source material.7374When demonstrating spacing or braces, include examples such as `if (x)`, not `if(x)`, and sample calls like `do_something` and `do_something_else` only as illustrative placeholders.7576## Standards content7778| Section | Infer from source |79| --- | --- |80| Introduction | Purpose, scope, language, package, and project context. |81| Naming conventions | Variables such as `camelCase` or `lower_snake_case`, functions/methods, classes/structs, constants like `UPPER_SNAKE_CASE`, and file naming. |82| Formatting and style | Indentation, line length, braces such as K&R or Allman, blank lines, UTF-8/no BOM, final newline. |83| Comments and documentation | Docstrings, inline comments, file headers, `TODO`, `FIXME`, and `NOTE` practices. |84| Error handling | Exception types, returned errors, logging expectations, cleanup requirements. |85| Best practices and anti-patterns | Global variables, magic numbers, repetition, unused code, and language-specific rules. |86| Examples | One correct and one corrected bad example when useful. |87| Contribution and enforcement | Code review expectations, tests, and guide maintenance. |8889## Style reference map9091When `fetchStyleURL` is true, use only the relevant language or ecosystem links:9293| Language or ecosystem | URL |94| --- | --- |95| C Style Guide | `https://users.ece.cmu.edu/~eno/coding/CCodingStandard.html` |96| C# Style Guide | `https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions` |97| C++ Style Guide | `https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines` |98| Go Style Guide | `https://github.com/golang-standards/project-layout` |99| Java Style Guide | `https://coderanch.com/wiki/718799/Style` |100| AngularJS App Style Guide | `https://github.com/mgechev/angularjs-style-guide` |101| jQuery Style Guide | `https://contribute.jquery.org/style-guide/js/` |102| JavaScript Style Guide | `https://www.w3schools.com/js/js_conventions.asp` |103| JSON Style Guide | `https://google.github.io/styleguide/jsoncstyleguide.xml` |104| Kotlin Style Guide | `https://kotlinlang.org/docs/coding-conventions.html` |105| Markdown Style Guide | `https://cirosantilli.com/markdown-style-guide/` |106| Perl Style Guide | `https://perldoc.perl.org/perlstyle` |107| PHP Style Guide | `https://phptherightway.com/` |108| Python Style Guide | `https://peps.python.org/pep-0008/` |109| Ruby Style Guide | `https://rubystyle.guide/` |110| Rust Style Guide | `https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide/src` |111| Swift Style Guide | `https://www.swift.org/documentation/api-design-guidelines/` |112| TypeScript Style Guide | `https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html` |113| Visual Basic Style Guide | `https://en.wikibooks.org/wiki/Visual_Basic/Coding_Standards` |114| Shell Script Style Guide | `https://google.github.io/styleguide/shellguide.html` |115| Git Usage Style Guide | `https://github.com/agis/git-style-guide` |116| PowerShell Style Guide | `https://github.com/PoshCode/PowerShellPracticeAndStyle` |117| CSS | `https://cssguidelin.es/` |118| Sass Style Guide | `https://sass-guidelin.es/` |119| HTML Style Guide | `https://github.com/marcobiedermann/html-style-guide` |120| Linux kernel Style Guide | `https://www.kernel.org/doc/html/latest/process/coding-style.html` |121| Node.js Style Guide | `https://github.com/felixge/node-style-guide` |122| SQL Style Guide | `https://www.sqlstyle.guide/` |123| Angular Style Guide | `https://angular.dev/style-guide` |124| Vue Style Guide | `https://vuejs.org/style-guide/rules-strongly-recommended.html` |125| Django Style Guide | `https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/` |126| SystemVerilog Style Guide | `https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md` |127128## Examples129130### Minimal template131132Use for small projects or when `useTemplate` is `"m"` or `"minimal"`.133134```markdown135## 1. Introduction136* **Purpose:** Briefly explain why the coding standards are being established.137* **Scope:** Define which languages, projects, or modules this specification applies to.138139## 2. Naming Conventions140* **Variables:** `camelCase`141* **Functions/Methods:** `PascalCase` or `camelCase`.142* **Classes/Structs:** `PascalCase`.143* **Constants:** `UPPER_SNAKE_CASE`.144145## 3. Formatting and Style146* **Indentation:** Use 4 spaces per indent or tabs.147* **Line Length:** Limit lines to a maximum of 80 or 120 characters.148* **Braces:** Use K&R or Allman style.149* **Blank Lines:** Specify separation between logical blocks.150151## 4. Commenting152* **Docstrings/Function Comments:** Describe purpose, parameters, and return values.153* **Inline Comments:** Explain complex or non-obvious logic.154* **File Headers:** Specify author, date, and file description if the project uses them.155156## 5. Error Handling157* **General:** How to handle and log errors.158* **Specifics:** Which exception types to use and what to include in error messages.159160## 6. Best Practices and Anti-Patterns161* **General:** Avoid global variables and magic numbers.162* **Language-specific:** Add project-specific recommendations.163164## 7. Examples165* Provide correct and incorrect examples.166167## 8. Contribution and Enforcement168* Explain review and enforcement.169```170171### Verbose template172173Use for larger projects, or when `useTemplate` is `"v"` or `"verbose"`.174175```markdown176# Style Guide177178This document defines the style and conventions used in this project.179All contributions should follow these rules unless otherwise noted.180181## 1. General Code Style182- Favor clarity over brevity.183- Keep functions and methods small and focused.184- Avoid repeating logic; prefer shared helpers/utilities.185- Remove unused variables, imports, code paths, and files.186187## 2. Naming Conventions188| Item | Convention | Example |189| --- | --- | --- |190| Variables | `lower_snake_case` | `buffer_size` |191| Functions | `lower_snake_case()` | `read_file()` |192| Constants | `UPPER_SNAKE_CASE` | `MAX_RETRIES` |193| Types/Structs | `PascalCase` | `FileHeader` |194| File Names | `lower_snake_case` | `file_reader.c` |195196## 3. Formatting Rules197- Indentation: **4 spaces**198- Line length: **max 100 characters**199- Encoding: **UTF-8**, no BOM200- End files with a newline201202## 4. Comments & Documentation203- Explain why, not what, unless intent is unclear.204- Keep comments up-to-date as code changes.205- Public functions should include a short description of purpose and parameters.206- Tags: `TODO: follow-up work`, `FIXME: known incorrect behavior`, `NOTE: non-obvious design decision`.207208## 5. Error Handling209- Handle error conditions explicitly.210- Avoid silent failures.211- Clean up resources before returning on failure.212213## 6. Commit & Review Practices214- One logical change per commit.215- Write clear commit messages.216- Keep pull requests reasonably small.217218## 7. Tests219- Write tests for new functionality.220- Tests should be deterministic.221- Prefer readable test cases over complex test abstraction.222223## 8. Changes to This Guide224Style evolves. Propose improvements by updating this document.225```226227## Output template228229```markdown230## Coding standards result231232**Status:** created file | updated README.md | output only | blocked233**Source:** `<fileName or folderName>`234**Template:** minimal | verbose | best fit | custom235236### Style evidence237| Category | Majority pattern | Exceptions |238| --- | --- | --- |239| Indentation | <tabs/2/4 spaces> | <files or none> |240| Naming | <observed conventions> | <exceptions or none> |241| Comments | <docstring/comment style> | <exceptions or none> |242| Error handling | <observed approach> | <exceptions or none> |243244### Artifact245- `<CONTRIBUTING.md or STYLE.md or CODE_OF_CONDUCT.md or CODING_STANDARDS.md or DEVELOPING.md or CONTRIBUTION_GUIDE.md or GUIDELINES.md or PROJECT_STANDARDS.md or BEST_PRACTICES.md or HACKING.md or README.md>`246247### Inconsistencies248- <fixed or reported inconsistency>249250### Validation251- `fetchStyleURL`: true | false, <URL or not applicable>252- `findInconsistencies`: true | false253- `fixInconsistencies`: true | false254```255256## Quality gate257258- [ ] `fileName` is present or `folderName` provides a real file set to analyze.259- [ ] Multiple files are aggregated before standards are written.260- [ ] `fixInconsistencies` is disabled for multi-file or folder analysis unless the user explicitly accepts edits.261- [ ] The output location honors `addToREADME`, `createNewFile`, and `outputSpecToPrompt` precedence.262- [ ] `newFileName` uses the first missing candidate or the exact string supplied by the user.263- [ ] Style rules are backed by observed source evidence, fetched reference guidance, or explicit user `instructions`.264- [ ] Every inconsistency that is fixed or reported is tied to a counted minority pattern.265266## References267268- [C Style Guide](https://users.ece.cmu.edu/~eno/coding/CCodingStandard.html)269- [C# Style Guide](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions)270- [C++ Style Guide](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)271- [Go Style Guide](https://github.com/golang-standards/project-layout)272- [Java Style Guide](https://coderanch.com/wiki/718799/Style)273- [AngularJS App Style Guide](https://github.com/mgechev/angularjs-style-guide)274- [jQuery Style Guide](https://contribute.jquery.org/style-guide/js/)275- [JavaScript Style Guide](https://www.w3schools.com/js/js_conventions.asp)276- [JSON Style Guide](https://google.github.io/styleguide/jsoncstyleguide.xml)277- [Kotlin Style Guide](https://kotlinlang.org/docs/coding-conventions.html)278- [Markdown Style Guide](https://cirosantilli.com/markdown-style-guide/)279- [Perl Style Guide](https://perldoc.perl.org/perlstyle)280- [PHP Style Guide](https://phptherightway.com/)281- [Python Style Guide](https://peps.python.org/pep-0008/)282- [Ruby Style Guide](https://rubystyle.guide/)283- [Rust Style Guide](https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide/src)284- [Swift Style Guide](https://www.swift.org/documentation/api-design-guidelines/)285- [TypeScript Style Guide](https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html)286- [Visual Basic Style Guide](https://en.wikibooks.org/wiki/Visual_Basic/Coding_Standards)287- [Shell Script Style Guide](https://google.github.io/styleguide/shellguide.html)288- [Git Usage Style Guide](https://github.com/agis/git-style-guide)289- [PowerShell Style Guide](https://github.com/PoshCode/PowerShellPracticeAndStyle)290- [CSS](https://cssguidelin.es/)291- [Sass Style Guide](https://sass-guidelin.es/)292- [HTML Style Guide](https://github.com/marcobiedermann/html-style-guide)293- [Linux kernel Style Guide](https://www.kernel.org/doc/html/latest/process/coding-style.html)294- [Node.js Style Guide](https://github.com/felixge/node-style-guide)295- [SQL Style Guide](https://www.sqlstyle.guide/)296- [Angular Style Guide](https://angular.dev/style-guide)297- [Vue Style Guide](https://vuejs.org/style-guide/rules-strongly-recommended.html)298- [Django Style Guide](https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/)299- [SystemVerilog Style Guide](https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md)