code-style-enforcer

Analyzes code for style consistency and applies project-specific formatting conventions beyond what linters catch. Use when reviewing code, ensuring style consistency, or when user requests code style improvements.

242 stars

Best use case

code-style-enforcer is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. Analyzes code for style consistency and applies project-specific formatting conventions beyond what linters catch. Use when reviewing code, ensuring style consistency, or when user requests code style improvements.

Analyzes code for style consistency and applies project-specific formatting conventions beyond what linters catch. Use when reviewing code, ensuring style consistency, or when user requests code style improvements.

Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.

Practical example

Example input

Use the "code-style-enforcer" skill to help with this workflow task. Context: Analyzes code for style consistency and applies project-specific formatting conventions beyond what linters catch. Use when reviewing code, ensuring style consistency, or when user requests code style improvements.

Example output

A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.

When to use this skill

  • Use this skill when you want a reusable workflow rather than writing the same prompt again and again.

When not to use this skill

  • Do not use this when you only need a one-off answer and do not need a reusable workflow.
  • Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/code-style-enforcer/SKILL.md --create-dirs "https://raw.githubusercontent.com/aiskillstore/marketplace/main/skills/crazydubya/code-style-enforcer/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/code-style-enforcer/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How code-style-enforcer Compares

Feature / Agentcode-style-enforcerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Analyzes code for style consistency and applies project-specific formatting conventions beyond what linters catch. Use when reviewing code, ensuring style consistency, or when user requests code style improvements.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Code Style Enforcer

This skill ensures code follows project-specific style conventions and patterns that automated linters may miss.

## When to Use This Skill

- User requests code style review or improvements
- Ensuring consistency across the codebase
- Onboarding new code or contributors
- Pre-commit code review
- User mentions "style", "consistency", "formatting", or "conventions"

## Instructions

### 1. Detect Project Style Guides

Look for style configuration files:

**JavaScript/TypeScript:**
- `.eslintrc.*` - ESLint configuration
- `.prettierrc.*` - Prettier configuration
- `tsconfig.json` - TypeScript compiler options
- `.editorconfig` - Editor configuration

**Python:**
- `.pylintrc`, `pylint.cfg` - Pylint
- `pyproject.toml` - Black, isort configuration
- `.flake8` - Flake8 configuration
- `setup.cfg` - Various tool configs

**Ruby:**
- `.rubocop.yml` - RuboCop configuration

**Go:**
- `go.fmt` enforced (standard)
- `.golangci.yml` - GolangCI-Lint

**Java:**
- `checkstyle.xml` - Checkstyle
- `.editorconfig`

**General:**
- `CONTRIBUTING.md` - Contribution guidelines
- `STYLE_GUIDE.md` - Project style guide
- `.editorconfig` - Cross-editor settings

Use Glob to find these files and Read to understand the project's style preferences.

### 2. Analyze Existing Code Patterns

Sample existing code to understand implicit conventions:

**File organization:**
- Directory structure patterns
- File naming conventions (camelCase, kebab-case, snake_case)
- Import/export organization

**Code structure:**
- Class/function ordering
- Public vs private method placement
- Constant/variable declaration location

**Formatting:**
- Indentation (spaces vs tabs, size)
- Line length limits
- Blank line usage
- Comment styles

**Naming:**
- Variable naming (camelCase, snake_case)
- Class naming (PascalCase, capitalization)
- Constant naming (UPPER_CASE, etc.)
- File naming patterns

Use Grep to find common patterns across similar files.

### 3. Beyond Linters: Check for Patterns

Focus on style issues that automated tools often miss:

**Naming Consistency:**
- Boolean variables: `is`, `has`, `should` prefixes
- Event handlers: `handle*`, `on*` patterns
- Getters/setters: `get*`, `set*` consistency
- Collection naming: plural vs singular
- Acronyms: consistent capitalization

**Code Organization:**
- Related functions grouped together
- Consistent file structure across modules
- Logical ordering (public before private, etc.)
- Separation of concerns

**Comments and Documentation:**
- JSDoc/docstring completeness
- Comment style consistency
- TODO/FIXME format
- Inline vs block comments

**Import/Export Patterns:**
- Import ordering (external, internal, relative)
- Named vs default exports
- Destructuring consistency
- Aliasing patterns

**Error Handling:**
- Consistent error message format
- Error class usage
- Try/catch patterns
- Logging format

**Type Usage (TypeScript/typed languages):**
- Explicit vs inferred types
- `interface` vs `type` preference
- Generic naming (T, K, V vs descriptive)
- Null/undefined handling

### 4. Identify Common Anti-Patterns

Flag code smells and anti-patterns:

**Magic Numbers:**
```javascript
// Bad
if (status === 200) { }

// Good
const HTTP_OK = 200;
if (status === HTTP_OK) { }
```

**Inconsistent null checks:**
```javascript
// Inconsistent
if (user === null) { }
if (!data) { }
if (typeof result === 'undefined') { }

// Consistent
if (user === null) { }
if (data === null) { }
if (result === undefined) { }
```

**Nested ternaries:**
```javascript
// Hard to read
const value = a ? b ? c : d : e;

// Better
let value;
if (a) {
  value = b ? c : d;
} else {
  value = e;
}
```

**Long parameter lists:**
```python
# Hard to maintain
def create_user(name, email, age, address, phone, ...):

# Better
def create_user(user_data: UserData):
```

### 5. Check Project-Specific Conventions

Look for patterns unique to this project:

- Custom naming for specific domains (e.g., "repo" vs "repository")
- Preferred libraries for common tasks
- Architectural patterns (MVC, service layer, etc.)
- Test file naming and structure
- Configuration patterns

Read `CONTRIBUTING.md`, `README.md`, or similar docs for explicit guidelines.

### 6. Generate Style Recommendations

For each issue, provide:

**Current code:**
```javascript
function getData(id) {
  const d = fetch('/api/users/' + id);
  return d;
}
```

**Issue:**
- Inconsistent naming (`getData` vs other functions use `fetch*`)
- Single-letter variable name (`d`)
- String concatenation instead of template literals

**Recommended:**
```javascript
function fetchUser(id) {
  const userData = fetch(`/api/users/${id}`);
  return userData;
}
```

### 7. Prioritize Issues

Order by impact:

**High Priority (Consistency):**
- Naming inconsistencies across similar functions
- Mixed indentation or formatting
- Inconsistent error handling

**Medium Priority (Readability):**
- Magic numbers/strings
- Unclear variable names
- Missing documentation

**Low Priority (Nice-to-have):**
- Comment formatting
- Import ordering
- Extra blank lines

### 8. Suggest Automated Tools

Recommend tools to enforce styles:

**JavaScript/TypeScript:**
```bash
npm install --save-dev prettier eslint
npx prettier --write .
npx eslint --fix .
```

**Python:**
```bash
pip install black isort flake8
black .
isort .
```

**Go:**
```bash
go fmt ./...
golangci-lint run
```

**Ruby:**
```bash
gem install rubocop
rubocop -a
```

### 9. Create or Update EditorConfig

Suggest `.editorconfig` if missing:

```ini
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,ts,jsx,tsx}]
indent_style = space
indent_size = 2

[*.py]
indent_style = space
indent_size = 4

[*.go]
indent_style = tab
```

### 10. Style Review Checklist

When reviewing code for style:

- [ ] Naming follows project conventions
- [ ] Indentation and formatting consistent
- [ ] Imports organized properly
- [ ] Comments where needed, not excessive
- [ ] No magic numbers or strings
- [ ] Error handling consistent
- [ ] File organization matches project structure
- [ ] No obvious code smells
- [ ] Type annotations consistent (if applicable)
- [ ] Tests follow testing conventions

## Best Practices

1. **Consistency over perfection**: Follow existing patterns even if not ideal
2. **Document decisions**: Add style guides for ambiguous cases
3. **Automate where possible**: Use Prettier, Black, gofmt, etc.
4. **Be pragmatic**: Don't refactor working code just for style
5. **Team agreement**: Align on styles that matter
6. **Incremental improvement**: Fix styles in touched files, not all at once
7. **Readability first**: Style serves readability, not vice versa

## Common Style Conflicts

### Tabs vs Spaces
- Check `.editorconfig` or existing files
- When in doubt, use project majority

### Quote Style (Single vs Double)
- JavaScript: Single (`'`) common
- Python: Either, be consistent
- Go: Always double (`"`)
- Follow linter config if present

### Semicolons (JavaScript)
- Check existing code majority
- If mixed, suggest Prettier to enforce

### Line Length
- Common limits: 80, 100, 120 characters
- Check linter config or `.editorconfig`

### Import Ordering
- Usually: stdlib, external, internal, relative
- Use automated tools (isort, organize imports)

## Supporting Files

- `reference/style-guides.md`: Links to popular style guides
- `examples/before-after.md`: Code examples showing improvements

Related Skills

design-style-skill

242
from aiskillstore/marketplace

Select a consistent visual design system for PPT slides using radius/spacing style recipes. Use when users ask for overall style direction or component styling consistency. Includes Sharp/Soft/Rounded/Pill recipes, component mappings, typography/spacing rules, and mixing guidance. Triggers: 风格, style, radius, spacing, 圆角, 间距, PPT风格, 视觉风格, design style, component style.

generating-output-styles

242
from aiskillstore/marketplace

Creates custom output styles for Claude Code that modify system prompts and behavior. Use when the user asks to create output styles, customize Claude's response format, generate output-style files, or mentions output style configuration.

when-auditing-code-style-use-style-audit

242
from aiskillstore/marketplace

Code style and conventions audit with auto-fix capabilities for comprehensive style enforcement

style-audit

242
from aiskillstore/marketplace

Audits code against CI/CD style rules, quality guidelines, and best practices, then rewrites code to meet standards without breaking functionality. Use this skill after functionality validation to ensure code is not just correct but also maintainable, readable, and production-ready. The skill applies linting rules, enforces naming conventions, improves code organization, and refactors for clarity while preserving all behavioral correctness verified by functionality audits.

devflow-tdd-enforcer

242
from aiskillstore/marketplace

Enforces TDD order in TASKS.md - Tests MUST be marked complete before Implementation tasks. Blocks violations in real-time.

global-coding-style

242
from aiskillstore/marketplace

Maintain consistent code formatting, naming conventions, type safety, and automated code quality standards across PHP and TypeScript/JavaScript. Use this skill when writing or editing any PHP files (.php), TypeScript/JavaScript files (.ts, .tsx, .js, .jsx), when implementing type declarations and return types, when running code formatters (Laravel Pint, Ultracite) or linters, when running static analysis tools (Larastan), when naming variables, functions, classes, or files, when applying DRY principles, when removing dead code, or when preparing code for review or commit.

ui-style-guide

242
from aiskillstore/marketplace

Frontend coding standards, component patterns, and design system for the Guessimate Angular UI. Reference when writing or reviewing frontend code.

git-workflow-enforcer

242
from aiskillstore/marketplace

Ensures commits follow conventional commits, branch naming conventions, and PR templates. Use when creating commits, branches, or PRs, or when user mentions git workflow.

python-style-guide

242
from aiskillstore/marketplace

Comprehensive Python programming guidelines based on Google's Python Style Guide. Use when Claude needs to write Python code, review Python code for style issues, refactor Python code, or provide Python programming guidance. Covers language rules (imports, exceptions, type annotations), style rules (naming conventions, formatting, docstrings), and best practices for clean, maintainable Python code.

art-style-creator

242
from aiskillstore/marketplace

Create and define visual art styles for projects. Use when user wants to establish an art direction, create a style guide, define visual language, document aesthetic choices, or create consistent artwork guidelines for games, illustrations, animations, or other visual media.

tdd-enforcer

242
from aiskillstore/marketplace

Use when implementing new features. Enforces TDD workflow - write tests FIRST, then implementation. Ensures AAA pattern, proper coverage, and quality test design.

grammar-and-style-enhancer

242
from aiskillstore/marketplace

Improves text quality by enhancing grammar, vocabulary, narrative clarity, flow, pacing, and writing style while preserving the author’s voice.