Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/check-agent-skills.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Check Agent Skills

on:
push:
branches: [ main, master, gh-pages ]
pull_request:
branches: [ main, master, gh-pages ]

jobs:
check-skills:
# Run the checks on the latest Ubuntu environment
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository code to access the files locally
- name: Checkout Code
uses: actions/checkout@v4

# Step 2: Extract the list of style guide reference keys from the README.md references block
- name: Extract Style Guide Keys from README.md
run: |
# Extract all style guide reference keys defined between the START/END markers,
# remove the brackets and colon, and sort the list alphabetically.
echo "Extracting style guide keys from README.md..."
README_KEYS=$(sed -n '/<!-- START_STYLEGUIDES -->/,/<!-- END_STYLEGUIDES -->/p' README.md \
| grep -E '^\[[a-zA-Z0-9_-]+\]:' \
| grep -o -E '^\[[a-zA-Z0-9_-]+\]' \
| tr -d '[]' \
| sort)

# Write the list to a temporary file for differential comparison in a later step
echo "$README_KEYS" > readme_keys.tmp

# Step 3: Extract the list of style guide languages from SKILL.md and normalize them to keys
- name: Extract Style Guide Keys from SKILL.md
run: |
# Extract the Language column values from the Supported Style Guides table in SKILL.md,
# convert to lowercase, remove markdown formatting, and map them to their corresponding
# README reference keys (using a normalized sed translation map).
echo "Extracting style guide keys from SKILL.md..."
SKILL_KEYS=$(grep '|' skills/google-styleguide/SKILL.md \
| tail -n +3 \
| cut -d'|' -f2 \
| tr -d '* ' \
| tr '[:upper:]' '[:lower:]' \
| sed -E -e 's/angularjs/angular/' \
-e 's/commonlisp/cl/' \
-e 's/c\+\+/cpp/' \
-e 's/c#/csharp/' \
-e 's/html\/css/htmlcss/' \
-e 's/javascript/js/' \
-e 's/objective-c/objc/' \
-e 's/python/py/' \
-e 's/shell/sh/' \
-e 's/typescript/ts/' \
-e 's/vimscript/vim/' \
| sort)

# Write the list to a temporary file for differential comparison in a later step
echo "$SKILL_KEYS" > skill_keys.tmp

# Step 4: Compare the two sets of keys and fail if they have diverged
- name: Verify README.md and SKILL.md style guides are in sync
run: |
# Perform a differential comparison between the two sets of extracted reference keys
DIFF_OUT=$(diff readme_keys.tmp skill_keys.tmp || true)

# Clean up temporary files
rm -f readme_keys.tmp skill_keys.tmp

# Fail the build if any divergence is found
if [[ -n "$DIFF_OUT" ]]; then
echo "Error: README.md style guides and skills/google-styleguide/SKILL.md support different languages!" >&2
echo "Differences (- README.md, + SKILL.md):" >&2
echo "$DIFF_OUT" >&2
exit 1
else
echo "Success: README.md and skills/google-styleguide/SKILL.md supported languages are in sync!"
exit 0
fi
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ primarily optimizing for Google's internal needs.

<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>

<!-- START_STYLEGUIDES -->
[cpp]: https://google.github.io/styleguide/cppguide.html
[csharp]: https://google.github.io/styleguide/csharp-style.html
[swift]: https://google.github.io/swift/
[objc]: objcguide.md
[gh-tracker]: https://github.com/google/styleguide/issues
[go]: go/
[java]: https://google.github.io/styleguide/javaguide.html
[json]: https://google.github.io/styleguide/jsoncstyleguide.xml
Expand All @@ -94,9 +94,13 @@ primarily optimizing for Google's internal needs.
[angular]: https://google.github.io/styleguide/angularjs-google-style.html
[cl]: https://google.github.io/styleguide/lispguide.xml
[vim]: https://google.github.io/styleguide/vimscriptguide.xml
[emacs]: https://raw.githubusercontent.com/google/styleguide/gh-pages/google-c-style.el
[xml]: https://google.github.io/styleguide/xmlstyle.html
[dart]: https://www.dartlang.org/guides/language/effective-dart
<!-- END_STYLEGUIDES -->

[gh-tracker]: https://github.com/google/styleguide/issues
[emacs]: https://raw.githubusercontent.com/google/styleguide/gh-pages/google-c-style.el
[ccl]: https://creativecommons.org/licenses/by/3.0/
[SCM]: https://en.wikipedia.org/wiki/Source_control_management
[VCS]: https://en.wikipedia.org/wiki/Version_control_system

56 changes: 56 additions & 0 deletions skills/google-styleguide/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: google-styleguide
description: Validates and refactors code in the target codebase to adhere to the official Google Style Guides across multiple supported languages.
---

## Core Concept

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.

## Supported Style Guides

| Language | File Extensions | Style Guide URL |
| :--- | :--- | :--- |
| **AngularJS** | `.js`, `.html` | [AngularJS Style Guide](guides/angularjs-google-style.html) |
| **Common Lisp** | `.lisp`, `.lsp`, `.cl` | [Common Lisp Style Guide](guides/lispguide.xml) |
| **C++** | `.cpp`, `.cc`, `.cxx`, `.hpp`, `.h`, `.hh` | [C++ Style Guide](guides/cppguide.html) |
| **C#** | `.cs` | [C# Style Guide](guides/csharp-style.md) |
| **Dart** | `.dart` | [Effective Dart](https://www.dartlang.org/guides/language/effective-dart) |
| **Go** | `.go` | [Go Style Guide](guides/go/index.md) |
| **HTML/CSS** | `.html`, `.css` | [HTML/CSS Style Guide](guides/htmlcssguide.html) |
| **JavaScript** | `.js`, `.mjs`, `.cjs` | [JavaScript Style Guide](guides/jsguide.html) |
| **Java** | `.java` | [Java Style Guide](guides/javaguide.html) |
| **JSON** | `.json`, `.jsonc` | [JSON Style Guide](guides/jsoncstyleguide.xml) |
| **Kotlin** | `.kt`, `.kts` | [Kotlin Style Guide](https://developer.android.com/kotlin/style-guide) |
| **Markdown** | `.md` | [Markdown Style Guide](guides/docguide/style.md) |
| **Objective-C** | `.m`, `.mm`, `.h` | [Objective-C Style Guide](guides/objcguide.md) |
| **Python** | `.py`, `.pyi` | [Python Style Guide](guides/pyguide.md) |
| **R** | `.r`, `.R` | [R Style Guide](guides/Rguide.md) |
| **Shell** | `.sh`, `.bash`, `.zsh` | [Shell Style Guide](guides/shellguide.md) |
| **Swift** | `.swift` | [Swift Style Guide](https://google.github.io/swift/) |
| **TypeScript** | `.ts`, `.tsx` | [TypeScript Style Guide](guides/tsguide.html) |
| **Vim script** | `.vim`, `.vimrc` | [Vim script Style Guide](guides/vimscriptguide.xml) |
| **XML** | `.xml` | [XML Document Format Style Guide](guides/xmlstyle.html) |

## Workflow Patterns

When invoked to check or refactor a codebase for style guide compliance:

### 1. Identify File Languages
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`).

### 2. Locate and Read the Style Guide
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:
- **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.
- **External Guides**: If the guide points to a remote URL (Dart, Kotlin, Swift), access the remote documentation using web browsing/reading tools.

### 3. Core Compliance Auditing
For each file being checked:
1. **Naming Conventions**: Check variable names, class names, method/function names, constants, and file names (e.g., `camelCase` vs `snake_case` or `PascalCase`).
2. **Formatting**: Ensure indentation (e.g., 2 spaces vs 4 spaces vs tabs), maximum line length, and brace placement conform.
3. **Language Features**: Ensure restricted language features are not used (e.g., no global variables, no raw exceptions in C++ unless specified, etc.).
4. **Imports/Includes**: Review import structures, sorting order, and use of absolute vs relative paths.
5. **Comments & Docs**: Ensure docstrings and file comments adhere to formatting, positioning, and language requirements.

### 4. Non-Destructive Refactoring
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.
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/Rguide.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/cppguide.html
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/csharp-style.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/docguide/README.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/docguide/READMEs.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/docguide/VERSION
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/docguide/best_practices.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/docguide/philosophy.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/docguide/style.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/go/best-practices.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/go/decisions.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/go/guide.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/go/index.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/htmlcssguide.html
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/javaguide.html
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/jsguide.html
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/jsoncstyleguide.xml
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/lispguide.xml
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/objcguide.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/pyguide.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/shellguide.md
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/tsguide.html
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/vimscriptguide.xml
1 change: 1 addition & 0 deletions skills/google-styleguide/guides/xmlstyle.html
1 change: 1 addition & 0 deletions skills/google-styleguide/resources/google-c-style.el
1 change: 1 addition & 0 deletions skills/google-styleguide/resources/google_python_style.vim
1 change: 1 addition & 0 deletions skills/google-styleguide/resources/javaguide.css
1 change: 1 addition & 0 deletions skills/google-styleguide/resources/pylintrc
1 change: 1 addition & 0 deletions skills/google-styleguide/resources/styleguide.css
1 change: 1 addition & 0 deletions skills/google-styleguide/resources/styleguide.xsl
Loading