Skip to content

Commit 8d48afe

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

30 files changed

Lines changed: 190 additions & 2 deletions
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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 URLs from the README.md references block
33+
- name: Extract Style Guide URLs from README.md
34+
run: |
35+
# Extract all style guide reference URLs defined between the START/END markers,
36+
# remove the reference tag prefix, map local relative references (like objc/go)
37+
# to their online published equivalents, and sort the list alphabetically.
38+
echo "Extracting style guides from README.md..."
39+
README_URLS=$(sed -n '/<!-- START_STYLEGUIDES -->/,/<!-- END_STYLEGUIDES -->/p' README.md \
40+
| grep -E '^\[[a-zA-Z0-9_-]+\]:' \
41+
| sed -E 's/^\[[^]]+\]:[[:space:]]+//' \
42+
| sed -E 's|^objcguide\.md$|https://google.github.io/styleguide/objcguide.html|' \
43+
| sed -E 's|^go/$|https://google.github.io/styleguide/go/|' \
44+
| sort)
45+
46+
# Write the list to a temporary file for differential comparison in a later step
47+
echo "$README_URLS" > readme_urls.tmp
48+
49+
# Step 3: Extract the list of style guide URLs defined in the SKILL.md table
50+
- name: Extract Style Guide URLs from SKILL.md
51+
run: |
52+
# Extract all URL targets from markdown links in the SKILL.md table
53+
# and sort the list alphabetically.
54+
echo "Extracting style guides from SKILL.md..."
55+
SKILL_URLS=$(grep '|' skills/google-styleguide/SKILL.md \
56+
| grep -o -E 'https?://[a-zA-Z0-9./_-]+' \
57+
| sort)
58+
59+
# Write the list to a temporary file for differential comparison in a later step
60+
echo "$SKILL_URLS" > skill_urls.tmp
61+
62+
# Step 4: Compare the two lists and fail if they have diverged
63+
- name: Verify README.md and SKILL.md style guides are in sync
64+
run: |
65+
# Perform a differential comparison between the extracted URL list files
66+
DIFF_OUT=$(diff readme_urls.tmp skill_urls.tmp || true)
67+
68+
# Clean up temporary files
69+
rm -f readme_urls.tmp skill_urls.tmp
70+
71+
# Fail the build if any divergence is found
72+
if [[ -n "$DIFF_OUT" ]]; then
73+
echo "Error: README.md style guides and skills/google-styleguide/SKILL.md are OUT OF SYNC!" >&2
74+
echo "Differences (- README.md, + SKILL.md):" >&2
75+
echo "$DIFF_OUT" >&2
76+
exit 1
77+
else
78+
echo "Success: README.md and skills/google-styleguide/SKILL.md are in sync!"
79+
exit 0
80+
fi
81+
82+
# Step 5: Setup Node.js runtime environment to run markdown-link-check tool
83+
- name: Set up Node.js
84+
uses: actions/setup-node@v4
85+
with:
86+
node-version: '20'
87+
88+
# Step 6: Validate that there are no broken links inside README.md or SKILL.md
89+
- name: Check Markdown Links
90+
run: |
91+
# Validate README.md links using the custom JSON config to bypass flaky domains
92+
npx markdown-link-check -c .github/workflows/mlc_config.json README.md
93+
# Validate SKILL.md links using the custom JSON config to bypass flaky domains
94+
npx markdown-link-check -c .github/workflows/mlc_config.json skills/google-styleguide/SKILL.md

.github/workflows/mlc_config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "wikipedia\\.org"
5+
},
6+
{
7+
"pattern": "creativecommons\\.org"
8+
}
9+
]
10+
}

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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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](https://google.github.io/styleguide/angularjs-google-style.html) |
15+
| **Common Lisp** | `.lisp`, `.lsp`, `.cl` | [Common Lisp Style Guide](https://google.github.io/styleguide/lispguide.xml) |
16+
| **C++** | `.cpp`, `.cc`, `.cxx`, `.hpp`, `.h`, `.hh` | [C++ Style Guide](https://google.github.io/styleguide/cppguide.html) |
17+
| **C#** | `.cs` | [C# Style Guide](https://google.github.io/styleguide/csharp-style.html) |
18+
| **Dart** | `.dart` | [Effective Dart](https://www.dartlang.org/guides/language/effective-dart) |
19+
| **Go** | `.go` | [Go Style Guide](https://google.github.io/styleguide/go/) |
20+
| **HTML/CSS** | `.html`, `.css` | [HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html) |
21+
| **JavaScript** | `.js`, `.mjs`, `.cjs` | [JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html) |
22+
| **Java** | `.java` | [Java Style Guide](https://google.github.io/styleguide/javaguide.html) |
23+
| **JSON** | `.json`, `.jsonc` | [JSON Style Guide](https://google.github.io/styleguide/jsoncstyleguide.xml) |
24+
| **Kotlin** | `.kt`, `.kts` | [Kotlin Style Guide](https://developer.android.com/kotlin/style-guide) |
25+
| **Markdown** | `.md` | [Markdown Style Guide](https://google.github.io/styleguide/docguide/style.html) |
26+
| **Objective-C** | `.m`, `.mm`, `.h` | [Objective-C Style Guide](https://google.github.io/styleguide/objcguide.html) |
27+
| **Python** | `.py`, `.pyi` | [Python Style Guide](https://google.github.io/styleguide/pyguide.html) |
28+
| **R** | `.r`, `.R` | [R Style Guide](https://google.github.io/styleguide/Rguide.html) |
29+
| **Shell** | `.sh`, `.bash`, `.zsh` | [Shell Style Guide](https://google.github.io/styleguide/shellguide.html) |
30+
| **Swift** | `.swift` | [Swift Style Guide](https://google.github.io/swift/) |
31+
| **TypeScript** | `.ts`, `.tsx` | [TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html) |
32+
| **Vim script** | `.vim`, `.vimrc` | [Vim script Style Guide](https://google.github.io/styleguide/vimscriptguide.xml) |
33+
| **XML** | `.xml` | [XML Document Format Style Guide](https://google.github.io/styleguide/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 the Corresponding Style Guide
43+
Refer to the table above. Access the online Style Guide URL to review rules relevant to the codebase files.
44+
45+
### 3. Core Compliance Auditing
46+
For each file being checked:
47+
1. **Naming Conventions**: Check variable names, class names, method/function names, constants, and file names (e.g., `camelCase` vs `snake_case` or `PascalCase`).
48+
2. **Formatting**: Ensure indentation (e.g., 2 spaces vs 4 spaces vs tabs), maximum line length, and brace placement conform.
49+
3. **Language Features**: Ensure restricted language features are not used (e.g., no global variables, no raw exceptions in C++ unless specified, etc.).
50+
4. **Imports/Includes**: Review import structures, sorting order, and use of absolute vs relative paths.
51+
5. **Comments & Docs**: Ensure docstrings and file comments adhere to formatting, positioning, and language requirements.
52+
53+
### 4. Non-Destructive Refactoring
54+
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

skills/google-styleguide/guides/go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../go

0 commit comments

Comments
 (0)