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-file-23description: 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# Write coding standards from file78Analyze 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.910## When to invoke1112- "Create coding standards from this file."13- "Infer our style guide from this folder."14- "Write CODING_STANDARDS.md based on these examples."15- "Add project coding standards to README.md."16- "Find and fix inconsistencies while generating the guide."1718## Inputs1920Use `$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.2122| Parameter | Required | Meaning |23| --- | --- | --- |24| `fileName` | Yes | File analyzed for indentation, variable naming, commenting, conditional procedures, functional procedures, and syntax style. |25| `folderName` | No | Folder whose files are aggregated and analyzed as one dataset. |26| `instructions` | No | Extra rules, procedures, or unique-case guidance. |27| `[configVariableAsParameter]` | No | Override a default such as `useTemplate`, `addToREADME`, `createNewFile`, or `newFileName`. |2829## Configuration variables3031| Variable | Default | Rule |32| --- | --- | --- |33| `addStandardsTest` | `false` | When true, write a test file that checks whether the analyzed files adhere to the generated standards. |34| `addToREADME` | `false` | When true, insert standards into `README.md` and set `createNewFile=false`, `outputSpecToPrompt=false`. |35| `addToREADMEInsertions` | `["atBegin", "middle", "beforeEnd", "bestFitUsingContext"]` | Default to `beforeEnd`; controls where standards are inserted in `README.md`. |36| `createNewFile` | `true` | Create a standards file and set `outputSpecToPrompt=false`, `addToREADME=false`. |37| `fetchStyleURL` | `true` | Fetch the relevant language style URL from the reference list when a language can be identified. |38| `findInconsistencies` | `true` | Count indentation, line-break, comment, conditional/function nesting, and quote-wrapper patterns; record minority deviations. |39| `fixInconsistencies` | `true` | Edit low-count categories to match the majority when safe; set to `false` when more than one file or `folderName` is used. |40| `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`. |41| `outputSpecToPrompt` | `false` | Return standards in the response and set `createNewFile=false`, `addToREADME=false`. |42| `useTemplate` | `"verbose"` or `"v"` | Accept `[ ["v", "verbose"], ["m", "minimal"], ["b", "best fit"], ["custom"] ]`; `custom` uses the supplied instructions or template. |4344## Decision rules4546| Condition | Action |47| --- | --- |48| `${fileName}.length > 1 || ${folderName} != undefined` | Toggle `fixInconsistencies` to `false`. |49| `${addToREADME} == true` | Insert into `README.md`; disable `createNewFile` and `outputSpecToPrompt`. |50| `${addToREADMEInsertions} == "atBegin"` | Insert after the title in `README.md`. |51| `${addToREADMEInsertions} == "middle"` | Insert near the middle and adapt the standards heading to the README composition. |52| `${addToREADMEInsertions} == "beforeEnd"` | Insert at the end after a new line. |53| `${addToREADMEInsertions} == "bestFitUsingContext"` | Insert at the best fitting line based on README context and flow. |54| `${addStandardsTest} == true` | Write a standards adherence test after the standards file is complete. |55| `${createNewFile} == true` | Create a file from `newFileName`; disable README insertion and prompt-only output. |56| `${fetchStyleURL} == true` | For the detected language, fetch the relevant URL from `### Fetch Links` style references. |57| `${findInconsistencies} == true` | Categorize syntax patterns, count majority/minority forms, and store inconsistencies. |58| `${fixInconsistencies} == true` | Fix minority syntax categories using stored inconsistency evidence. |59| `typeof ${newFileName} == "string"` | Create exactly that file. |60| `typeof ${newFileName} != "string"` | Iterate the candidate list and use the first file that does not exist, then `break`. |61| `${outputSpecToPrompt} == true` | Return the standards instead of writing a file or README update. |62| `${useTemplate} == "v" || ${useTemplate} == "verbose"` | Use the verbose template. |63| `${useTemplate} == "m" || ${useTemplate} == "minimal"` | Use the minimal template. |64| `${useTemplate} == "b" || ${useTemplate} == "best"` | Pick the minimal or verbose template based on observed project complexity. |65| `${useTemplate} == "custom" || ${useTemplate} == "<ANY_NAME>"` | Use the custom prompt, instructions, template, or data supplied by the user. |666768## Compatibility tokens6970Keep 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.7172When 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.7374## Standards content7576| Section | Infer from source |77| --- | --- |78| Introduction | Purpose, scope, language, package, and project context. |79| Naming conventions | Variables such as `camelCase` or `lower_snake_case`, functions/methods, classes/structs, constants like `UPPER_SNAKE_CASE`, and file naming. |80| Formatting and style | Indentation, line length, braces such as K&R or Allman, blank lines, UTF-8/no BOM, final newline. |81| Comments and documentation | Docstrings, inline comments, file headers, `TODO`, `FIXME`, and `NOTE` practices. |82| Error handling | Exception types, returned errors, logging expectations, cleanup requirements. |83| Best practices and anti-patterns | Global variables, magic numbers, repetition, unused code, and language-specific rules. |84| Examples | One correct and one corrected bad example when useful. |85| Contribution and enforcement | Code review expectations, tests, and guide maintenance. |8687## Style reference map8889When `fetchStyleURL` is true, use only the relevant language or ecosystem links:9091| Language or ecosystem | URL |92| --- | --- |93| C Style Guide | `https://users.ece.cmu.edu/~eno/coding/CCodingStandard.html` |94| C# Style Guide | `https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions` |95| C++ Style Guide | `https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines` |96| Go Style Guide | `https://github.com/golang-standards/project-layout` |97| Java Style Guide | `https://coderanch.com/wiki/718799/Style` |98| AngularJS App Style Guide | `https://github.com/mgechev/angularjs-style-guide` |99| jQuery Style Guide | `https://contribute.jquery.org/style-guide/js/` |100| JavaScript Style Guide | `https://www.w3schools.com/js/js_conventions.asp` |101| JSON Style Guide | `https://google.github.io/styleguide/jsoncstyleguide.xml` |102| Kotlin Style Guide | `https://kotlinlang.org/docs/coding-conventions.html` |103| Markdown Style Guide | `https://cirosantilli.com/markdown-style-guide/` |104| Perl Style Guide | `https://perldoc.perl.org/perlstyle` |105| PHP Style Guide | `https://phptherightway.com/` |106| Python Style Guide | `https://peps.python.org/pep-0008/` |107| Ruby Style Guide | `https://rubystyle.guide/` |108| Rust Style Guide | `https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide/src` |109| Swift Style Guide | `https://www.swift.org/documentation/api-design-guidelines/` |110| TypeScript Style Guide | `https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html` |111| Visual Basic Style Guide | `https://en.wikibooks.org/wiki/Visual_Basic/Coding_Standards` |112| Shell Script Style Guide | `https://google.github.io/styleguide/shellguide.html` |113| Git Usage Style Guide | `https://github.com/agis/git-style-guide` |114| PowerShell Style Guide | `https://github.com/PoshCode/PowerShellPracticeAndStyle` |115| CSS | `https://cssguidelin.es/` |116| Sass Style Guide | `https://sass-guidelin.es/` |117| HTML Style Guide | `https://github.com/marcobiedermann/html-style-guide` |118| Linux kernel Style Guide | `https://www.kernel.org/doc/html/latest/process/coding-style.html` |119| Node.js Style Guide | `https://github.com/felixge/node-style-guide` |120| SQL Style Guide | `https://www.sqlstyle.guide/` |121| Angular Style Guide | `https://angular.dev/style-guide` |122| Vue Style Guide | `https://vuejs.org/style-guide/rules-strongly-recommended.html` |123| Django Style Guide | `https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/` |124| SystemVerilog Style Guide | `https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md` |125126## Examples127128### Minimal template129130Use for small projects or when `useTemplate` is `"m"` or `"minimal"`.131132```markdown133## 1. Introduction134* **Purpose:** Briefly explain why the coding standards are being established.135* **Scope:** Define which languages, projects, or modules this specification applies to.136137## 2. Naming Conventions138* **Variables:** `camelCase`139* **Functions/Methods:** `PascalCase` or `camelCase`.140* **Classes/Structs:** `PascalCase`.141* **Constants:** `UPPER_SNAKE_CASE`.142143## 3. Formatting and Style144* **Indentation:** Use 4 spaces per indent or tabs.145* **Line Length:** Limit lines to a maximum of 80 or 120 characters.146* **Braces:** Use K&R or Allman style.147* **Blank Lines:** Specify separation between logical blocks.148149## 4. Commenting150* **Docstrings/Function Comments:** Describe purpose, parameters, and return values.151* **Inline Comments:** Explain complex or non-obvious logic.152* **File Headers:** Specify author, date, and file description if the project uses them.153154## 5. Error Handling155* **General:** How to handle and log errors.156* **Specifics:** Which exception types to use and what to include in error messages.157158## 6. Best Practices and Anti-Patterns159* **General:** Avoid global variables and magic numbers.160* **Language-specific:** Add project-specific recommendations.161162## 7. Examples163* Provide correct and incorrect examples.164165## 8. Contribution and Enforcement166* Explain review and enforcement.167```168169### Verbose template170171Use for larger projects, or when `useTemplate` is `"v"` or `"verbose"`.172173```markdown174# Style Guide175176This document defines the style and conventions used in this project.177All contributions should follow these rules unless otherwise noted.178179## 1. General Code Style180- Favor clarity over brevity.181- Keep functions and methods small and focused.182- Avoid repeating logic; prefer shared helpers/utilities.183- Remove unused variables, imports, code paths, and files.184185## 2. Naming Conventions186| Item | Convention | Example |187| --- | --- | --- |188| Variables | `lower_snake_case` | `buffer_size` |189| Functions | `lower_snake_case()` | `read_file()` |190| Constants | `UPPER_SNAKE_CASE` | `MAX_RETRIES` |191| Types/Structs | `PascalCase` | `FileHeader` |192| File Names | `lower_snake_case` | `file_reader.c` |193194## 3. Formatting Rules195- Indentation: **4 spaces**196- Line length: **max 100 characters**197- Encoding: **UTF-8**, no BOM198- End files with a newline199200## 4. Comments & Documentation201- Explain why, not what, unless intent is unclear.202- Keep comments up-to-date as code changes.203- Public functions should include a short description of purpose and parameters.204- Tags: `TODO: follow-up work`, `FIXME: known incorrect behavior`, `NOTE: non-obvious design decision`.205206## 5. Error Handling207- Handle error conditions explicitly.208- Avoid silent failures.209- Clean up resources before returning on failure.210211## 6. Commit & Review Practices212- One logical change per commit.213- Write clear commit messages.214- Keep pull requests reasonably small.215216## 7. Tests217- Write tests for new functionality.218- Tests should be deterministic.219- Prefer readable test cases over complex test abstraction.220221## 8. Changes to This Guide222Style evolves. Propose improvements by updating this document.223```224225## Output template226227```markdown228## Coding standards result229230**Status:** created file | updated README.md | output only | blocked231**Source:** `<fileName or folderName>`232**Template:** minimal | verbose | best fit | custom233234### Style evidence235| Category | Majority pattern | Exceptions |236| --- | --- | --- |237| Indentation | <tabs/2/4 spaces> | <files or none> |238| Naming | <observed conventions> | <exceptions or none> |239| Comments | <docstring/comment style> | <exceptions or none> |240| Error handling | <observed approach> | <exceptions or none> |241242### Artifact243- `<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>`244245### Inconsistencies246- <fixed or reported inconsistency>247248### Validation249- `fetchStyleURL`: true | false, <URL or not applicable>250- `findInconsistencies`: true | false251- `fixInconsistencies`: true | false252```253254## Quality gate255256- [ ] `fileName` is present or `folderName` provides a real file set to analyze.257- [ ] Multiple files are aggregated before standards are written.258- [ ] `fixInconsistencies` is disabled for multi-file or folder analysis unless the user explicitly accepts edits.259- [ ] The output location honors `addToREADME`, `createNewFile`, and `outputSpecToPrompt` precedence.260- [ ] `newFileName` uses the first missing candidate or the exact string supplied by the user.261- [ ] Style rules are backed by observed source evidence, fetched reference guidance, or explicit user `instructions`.262- [ ] Every inconsistency that is fixed or reported is tied to a counted minority pattern.263264## References265266- [C Style Guide](https://users.ece.cmu.edu/~eno/coding/CCodingStandard.html)267- [C# Style Guide](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions)268- [C++ Style Guide](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)269- [Go Style Guide](https://github.com/golang-standards/project-layout)270- [Java Style Guide](https://coderanch.com/wiki/718799/Style)271- [AngularJS App Style Guide](https://github.com/mgechev/angularjs-style-guide)272- [jQuery Style Guide](https://contribute.jquery.org/style-guide/js/)273- [JavaScript Style Guide](https://www.w3schools.com/js/js_conventions.asp)274- [JSON Style Guide](https://google.github.io/styleguide/jsoncstyleguide.xml)275- [Kotlin Style Guide](https://kotlinlang.org/docs/coding-conventions.html)276- [Markdown Style Guide](https://cirosantilli.com/markdown-style-guide/)277- [Perl Style Guide](https://perldoc.perl.org/perlstyle)278- [PHP Style Guide](https://phptherightway.com/)279- [Python Style Guide](https://peps.python.org/pep-0008/)280- [Ruby Style Guide](https://rubystyle.guide/)281- [Rust Style Guide](https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide/src)282- [Swift Style Guide](https://www.swift.org/documentation/api-design-guidelines/)283- [TypeScript Style Guide](https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html)284- [Visual Basic Style Guide](https://en.wikibooks.org/wiki/Visual_Basic/Coding_Standards)285- [Shell Script Style Guide](https://google.github.io/styleguide/shellguide.html)286- [Git Usage Style Guide](https://github.com/agis/git-style-guide)287- [PowerShell Style Guide](https://github.com/PoshCode/PowerShellPracticeAndStyle)288- [CSS](https://cssguidelin.es/)289- [Sass Style Guide](https://sass-guidelin.es/)290- [HTML Style Guide](https://github.com/marcobiedermann/html-style-guide)291- [Linux kernel Style Guide](https://www.kernel.org/doc/html/latest/process/coding-style.html)292- [Node.js Style Guide](https://github.com/felixge/node-style-guide)293- [SQL Style Guide](https://www.sqlstyle.guide/)294- [Angular Style Guide](https://angular.dev/style-guide)295- [Vue Style Guide](https://vuejs.org/style-guide/rules-strongly-recommended.html)296- [Django Style Guide](https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/)297- [SystemVerilog Style Guide](https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md)