|
| 1 | +--- |
| 2 | +name: google-styleguide |
| 3 | +description: Validates and refactors code in the target codebase to adhere to the official Google Style Guides across multiple supported languages. |
| 4 | +--- |
| 5 | + |
| 6 | +## Core Concept |
| 7 | + |
| 8 | +The `google-styleguide` skill ensures that a codebase conforms to Google's official style conventions. Because modern codebases often mix multiple languages, this skill helps identify language-specific files and checks each one against its corresponding style guide. |
| 9 | + |
| 10 | +## Supported Style Guides |
| 11 | + |
| 12 | +| Language | File Extensions | Style Guide URL | |
| 13 | +| :--- | :--- | :--- | |
| 14 | +| **AngularJS** | `.js`, `.html` | [AngularJS Style Guide](guides/angularjs-google-style.html) | |
| 15 | +| **Common Lisp** | `.lisp`, `.lsp`, `.cl` | [Common Lisp Style Guide](guides/lispguide.xml) | |
| 16 | +| **C++** | `.cpp`, `.cc`, `.cxx`, `.hpp`, `.h`, `.hh` | [C++ Style Guide](guides/cppguide.html) | |
| 17 | +| **C#** | `.cs` | [C# Style Guide](guides/csharp-style.md) | |
| 18 | +| **Dart** | `.dart` | [Effective Dart](https://www.dartlang.org/guides/language/effective-dart) | |
| 19 | +| **Go** | `.go` | [Go Style Guide](guides/go/index.md) | |
| 20 | +| **HTML/CSS** | `.html`, `.css` | [HTML/CSS Style Guide](guides/htmlcssguide.html) | |
| 21 | +| **JavaScript** | `.js`, `.mjs`, `.cjs` | [JavaScript Style Guide](guides/jsguide.html) | |
| 22 | +| **Java** | `.java` | [Java Style Guide](guides/javaguide.html) | |
| 23 | +| **JSON** | `.json`, `.jsonc` | [JSON Style Guide](guides/jsoncstyleguide.xml) | |
| 24 | +| **Kotlin** | `.kt`, `.kts` | [Kotlin Style Guide](https://developer.android.com/kotlin/style-guide) | |
| 25 | +| **Markdown** | `.md` | [Markdown Style Guide](guides/docguide/style.md) | |
| 26 | +| **Objective-C** | `.m`, `.mm`, `.h` | [Objective-C Style Guide](guides/objcguide.md) | |
| 27 | +| **Python** | `.py`, `.pyi` | [Python Style Guide](guides/pyguide.md) | |
| 28 | +| **R** | `.r`, `.R` | [R Style Guide](guides/Rguide.md) | |
| 29 | +| **Shell** | `.sh`, `.bash`, `.zsh` | [Shell Style Guide](guides/shellguide.md) | |
| 30 | +| **Swift** | `.swift` | [Swift Style Guide](https://google.github.io/swift/) | |
| 31 | +| **TypeScript** | `.ts`, `.tsx` | [TypeScript Style Guide](guides/tsguide.html) | |
| 32 | +| **Vim script** | `.vim`, `.vimrc` | [Vim script Style Guide](guides/vimscriptguide.xml) | |
| 33 | +| **XML** | `.xml` | [XML Document Format Style Guide](guides/xmlstyle.html) | |
| 34 | + |
| 35 | +## Workflow Patterns |
| 36 | + |
| 37 | +When invoked to check or refactor a codebase for style guide compliance: |
| 38 | + |
| 39 | +### 1. Identify File Languages |
| 40 | +Scan the current workspace to locate files matching the supported file extensions. Group files by language (e.g., Python files under `.py`, JavaScript files under `.js`). |
| 41 | + |
| 42 | +### 2. Locate and Read the Style Guide |
| 43 | +Determine which style guides are needed based on the file types present in the project. For each language under review, refer to the Supported Style Guides table above: |
| 44 | +- **Local Guides (Symlinked)**: If the guide points to a local file or folder path (e.g. `guides/cppguide.html`, `guides/pyguide.md`, `guides/go/index.md`, etc.), you **MUST** read the contents of that local file directly from this skill's directory using your file-viewing tools to get the style guidelines. |
| 45 | +- **External Guides**: If the guide points to a remote URL (Dart, Kotlin, Swift), access the remote documentation using web browsing/reading tools. |
| 46 | + |
| 47 | +### 3. Core Compliance Auditing |
| 48 | +For each file being checked: |
| 49 | +1. **Naming Conventions**: Check variable names, class names, method/function names, constants, and file names (e.g., `camelCase` vs `snake_case` or `PascalCase`). |
| 50 | +2. **Formatting**: Ensure indentation (e.g., 2 spaces vs 4 spaces vs tabs), maximum line length, and brace placement conform. |
| 51 | +3. **Language Features**: Ensure restricted language features are not used (e.g., no global variables, no raw exceptions in C++ unless specified, etc.). |
| 52 | +4. **Imports/Includes**: Review import structures, sorting order, and use of absolute vs relative paths. |
| 53 | +5. **Comments & Docs**: Ensure docstrings and file comments adhere to formatting, positioning, and language requirements. |
| 54 | + |
| 55 | +### 4. Non-Destructive Refactoring |
| 56 | +Make changes to files to match style guide specifications. Use precise code-editing tools to preserve all logic and behavior of the code. Run any existing test suites to verify functionality is not altered by styling changes. |
0 commit comments