Skip to content

Commit a00a986

Browse files
committed
feat: Add Google Style Guide coding assistant skill
1 parent 1809c76 commit a00a986

37 files changed

Lines changed: 189 additions & 2 deletions
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Check Agent Skills
16+
17+
on:
18+
push:
19+
branches: [ main, master, gh-pages ]
20+
pull_request:
21+
branches: [ main, master, gh-pages ]
22+
23+
jobs:
24+
check-skills:
25+
# Run the checks on the latest Ubuntu environment
26+
runs-on: ubuntu-latest
27+
steps:
28+
# Step 1: Checkout the repository code to access the files locally
29+
- name: Checkout Code
30+
uses: actions/checkout@v4
31+
32+
# Step 2: Extract the list of style guide reference keys from the README.md references block
33+
- name: Extract Style Guide Keys from README.md
34+
run: |
35+
# Extract all style guide reference keys defined between the START/END markers,
36+
# remove the brackets and colon, and sort the list alphabetically.
37+
echo "Extracting style guide keys from README.md..."
38+
README_KEYS=$(sed -n '/<!-- START_STYLEGUIDES -->/,/<!-- END_STYLEGUIDES -->/p' README.md \
39+
| grep -E '^\[[a-zA-Z0-9_-]+\]:' \
40+
| grep -o -E '^\[[a-zA-Z0-9_-]+\]' \
41+
| tr -d '[]' \
42+
| sort)
43+
44+
# Write the list to a temporary file for differential comparison in a later step
45+
echo "$README_KEYS" > readme_keys.tmp
46+
47+
# Step 3: Extract the list of style guide languages from SKILL.md and normalize them to keys
48+
- name: Extract Style Guide Keys from SKILL.md
49+
run: |
50+
# Extract the Language column values from the Supported Style Guides table in SKILL.md,
51+
# convert to lowercase, remove markdown formatting, and map them to their corresponding
52+
# README reference keys (using a normalized sed translation map).
53+
echo "Extracting style guide keys from SKILL.md..."
54+
SKILL_KEYS=$(grep '|' skills/google-styleguide/SKILL.md \
55+
| tail -n +3 \
56+
| cut -d'|' -f2 \
57+
| tr -d '* ' \
58+
| tr '[:upper:]' '[:lower:]' \
59+
| sed -E -e 's/angularjs/angular/' \
60+
-e 's/commonlisp/cl/' \
61+
-e 's/c\+\+/cpp/' \
62+
-e 's/c#/csharp/' \
63+
-e 's/html\/css/htmlcss/' \
64+
-e 's/javascript/js/' \
65+
-e 's/objective-c/objc/' \
66+
-e 's/python/py/' \
67+
-e 's/shell/sh/' \
68+
-e 's/typescript/ts/' \
69+
-e 's/vimscript/vim/' \
70+
| sort)
71+
72+
# Write the list to a temporary file for differential comparison in a later step
73+
echo "$SKILL_KEYS" > skill_keys.tmp
74+
75+
# Step 4: Compare the two sets of keys and fail if they have diverged
76+
- name: Verify README.md and SKILL.md style guides are in sync
77+
run: |
78+
# Perform a differential comparison between the two sets of extracted reference keys
79+
DIFF_OUT=$(diff readme_keys.tmp skill_keys.tmp || true)
80+
81+
# Clean up temporary files
82+
rm -f readme_keys.tmp skill_keys.tmp
83+
84+
# Fail the build if any divergence is found
85+
if [[ -n "$DIFF_OUT" ]]; then
86+
echo "Error: README.md style guides and skills/google-styleguide/SKILL.md support different languages!" >&2
87+
echo "Differences (- README.md, + SKILL.md):" >&2
88+
echo "$DIFF_OUT" >&2
89+
exit 1
90+
else
91+
echo "Success: README.md and skills/google-styleguide/SKILL.md supported languages are in sync!"
92+
exit 0
93+
fi

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ primarily optimizing for Google's internal needs.
7575

7676
<a rel="license" href="https://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/3.0/88x31.png" /></a>
7777

78+
<!-- START_STYLEGUIDES -->
7879
[cpp]: https://google.github.io/styleguide/cppguide.html
7980
[csharp]: https://google.github.io/styleguide/csharp-style.html
8081
[swift]: https://google.github.io/swift/
8182
[objc]: objcguide.md
82-
[gh-tracker]: https://github.com/google/styleguide/issues
8383
[go]: go/
8484
[java]: https://google.github.io/styleguide/javaguide.html
8585
[json]: https://google.github.io/styleguide/jsoncstyleguide.xml
@@ -94,9 +94,13 @@ primarily optimizing for Google's internal needs.
9494
[angular]: https://google.github.io/styleguide/angularjs-google-style.html
9595
[cl]: https://google.github.io/styleguide/lispguide.xml
9696
[vim]: https://google.github.io/styleguide/vimscriptguide.xml
97-
[emacs]: https://raw.githubusercontent.com/google/styleguide/gh-pages/google-c-style.el
9897
[xml]: https://google.github.io/styleguide/xmlstyle.html
9998
[dart]: https://www.dartlang.org/guides/language/effective-dart
99+
<!-- END_STYLEGUIDES -->
100+
101+
[gh-tracker]: https://github.com/google/styleguide/issues
102+
[emacs]: https://raw.githubusercontent.com/google/styleguide/gh-pages/google-c-style.el
100103
[ccl]: https://creativecommons.org/licenses/by/3.0/
101104
[SCM]: https://en.wikipedia.org/wiki/Source_control_management
102105
[VCS]: https://en.wikipedia.org/wiki/Version_control_system
106+

skills/google-styleguide/SKILL.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Rguide.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../angularjs-google-style.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../cppguide.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../csharp-style.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../docguide/README.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../docguide/READMEs.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../docguide/VERSION

0 commit comments

Comments
 (0)