style-guide-adherence
Use when writing code - follow Google style guides where available, otherwise follow established best practices for the language
What this skill does
# Style Guide Adherence
## Overview
Follow established style guides. Consistency over personal preference.
**Core principle:** Code is read more than written. Consistent style aids reading.
**Priority order:**
1. Project-specific style guide (if exists)
2. Google style guide (if available for language)
3. Language community best practices
## Google Style Guides
### Available Guides
| Language | Guide URL |
|----------|-----------|
| TypeScript/JavaScript | https://google.github.io/styleguide/tsguide.html |
| Python | https://google.github.io/styleguide/pyguide.html |
| Go | https://google.github.io/styleguide/go/ |
| Java | https://google.github.io/styleguide/javaguide.html |
| C++ | https://google.github.io/styleguide/cppguide.html |
| Shell | https://google.github.io/styleguide/shellguide.html |
| HTML/CSS | https://google.github.io/styleguide/htmlcssguide.html |
### Key Principles (All Languages)
| Principle | Description |
|-----------|-------------|
| Consistency | Match surrounding code style |
| Clarity | Prefer readable over clever |
| Simplicity | Simplest solution that works |
| Documentation | Document the why, not the what |
## TypeScript/JavaScript Style
### Naming
```typescript
// Classes: PascalCase
class UserService { }
// Interfaces: PascalCase (no I prefix)
interface User { } // NOT IUser
// Functions/methods: camelCase
function fetchUserData() { }
// Variables/parameters: camelCase
const userName = 'Alice';
// Constants: UPPER_SNAKE_CASE
const MAX_RETRIES = 3;
// Private members: no underscore prefix
class Service {
private cache: Map<string, Data>; // NOT _cache
}
// Files: kebab-case
// user-service.ts, not userService.ts or UserService.ts
```
### Formatting
```typescript
// Indent: 2 spaces
// Line length: 80 characters (100 max)
// Semicolons: required
// Quotes: single for strings
// Trailing commas: yes in multiline
const config = {
name: 'app',
version: '1.0.0',
features: [
'auth',
'logging',
],
};
```
### Imports
```typescript
// Order: external, then internal, then relative
// Alphabetize within groups
import { something } from 'external-lib';
import { other } from 'another-external';
import { internal } from '@/lib/internal';
import { local } from './local';
import { nearby } from '../nearby';
```
## Python Style
### Naming
```python
# Classes: PascalCase
class UserService:
pass
# Functions/variables: snake_case
def fetch_user_data():
pass
user_name = 'Alice'
# Constants: UPPER_SNAKE_CASE
MAX_RETRIES = 3
# Private: single underscore prefix
class Service:
def __init__(self):
self._cache = {} # internal use
def __private_method(self): # name mangling
pass
# Files: snake_case
# user_service.py
```
### Formatting
```python
# Indent: 4 spaces
# Line length: 80 characters
# Use Black formatter for consistency
# Imports order (use isort):
# 1. Standard library
# 2. Third-party
# 3. Local
import os
import sys
import requests
from flask import Flask
from myapp.utils import helper
```
### Docstrings
```python
def calculate_total(items: list[Item], tax_rate: float) -> float:
"""Calculate the total price including tax.
Args:
items: List of items to sum.
tax_rate: Tax rate as decimal (e.g., 0.08 for 8%).
Returns:
Total price including tax.
Raises:
ValueError: If tax_rate is negative.
"""
if tax_rate < 0:
raise ValueError("Tax rate cannot be negative")
subtotal = sum(item.price for item in items)
return subtotal * (1 + tax_rate)
```
## Go Style
### Naming
```go
// Exported: PascalCase
type UserService struct { }
func FetchUser() { }
// Unexported: camelCase
type internalCache struct { }
func fetchFromDB() { }
// Acronyms: consistent case
type HTTPClient struct { } // or httpClient for unexported
var userID string // NOT userId
// Files: snake_case
// user_service.go
```
### Formatting
Use `gofmt` - no options, no debate.
```bash
# Format all files
gofmt -w .
# Or use goimports for imports too
goimports -w .
```
## Enforcing Style
### Automated Tools
| Language | Formatter | Linter |
|----------|-----------|--------|
| TypeScript | Prettier | ESLint |
| Python | Black | Pylint, Ruff |
| Go | gofmt | golangci-lint |
| Rust | rustfmt | clippy |
### Configuration Files
Ensure these exist in the project:
**TypeScript/JavaScript:**
- `.eslintrc.js` or `eslint.config.js`
- `.prettierrc`
**Python:**
- `pyproject.toml` (Black, isort, mypy)
- `.pylintrc` or `ruff.toml`
**Go:**
- `.golangci.yml`
### Pre-commit Hooks
```yaml
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: format
name: Format code
entry: pnpm format
language: system
- id: lint
name: Lint code
entry: pnpm lint
language: system
```
## When Project Style Differs
If project has established style that differs from Google:
1. **Follow project style** - Consistency within project wins
2. **Document the difference** - Note in CONTRIBUTING.md
3. **Don't mix styles** - All code should match
```markdown
<!-- CONTRIBUTING.md -->
## Code Style
This project uses [specific style] which differs from Google style:
- We use tabs instead of spaces
- Line length is 120 characters
- [Other differences]
```
## Checking Style
Before committing:
```bash
# Run formatter
pnpm format # or black, gofmt, etc.
# Run linter
pnpm lint # or pylint, golangci-lint, etc.
# Fix auto-fixable issues
pnpm lint:fix
```
## Checklist
Before committing:
- [ ] Code formatted with project formatter
- [ ] No linting errors
- [ ] Naming follows conventions
- [ ] Imports organized
- [ ] Line length within limits
- [ ] Consistent with surrounding code
## Common Mistakes
| Mistake | Correction |
|---------|------------|
| Inconsistent naming | Follow project conventions |
| Long lines | Break at logical points |
| Mixed quote styles | Use project standard |
| Unorganized imports | Use import sorter |
| Manual formatting | Use automated formatter |
## Integration
This skill is applied by:
- `issue-driven-development` - Step 7
- `comprehensive-review` - Style criterion
This skill ensures:
- Readable code
- Easy reviews
- Reduced cognitive load
- Team consistency
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.