# Improve Go Code Style

Go code can pass formatting checks while still being hard to read. This skill guides Claude, Codex, and Claude Code toward clearer style choices.

## Install

```bash
npx skillstore add samber/golang-code-style
```

## Metadata

- Status: approved
- Slug: samber-golang-code-style
- Version: 1.2.0
- Author version: 1.2.0
- Skillstore revision: r1
- Version status: valid
- Tree hash: 55bcfd20b9b17d88922a6957295f35aa1bcc12f6bba92c9986564312b6534d49
- Author: samber
- GitHub username: samber
- License: MIT
- Repository: https://github.com/samber/cc-skills-golang/tree/main/skills/golang-code-style/
- Ref: e397ce5a135369cd6def89cb6400d013e2f68f2f
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, network
- Quality score: 77
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/samber-golang-code-style
- Manifest: https://skillstore.pages.dev/api/skills/samber-golang-code-style/manifest

## Capabilities

- Reviews Go code for line length, semantic line breaks, and readable call formatting.
- Guides variable declarations, empty slice initialization, and map initialization choices.
- Recommends early returns, simpler control flow, and fewer unnecessary else blocks.
- Advises when to use options structs instead of long parameter lists.
- Explains value versus pointer parameters for common Go types and structs.
- Supports large style reviews by splitting concerns across independent review passes.

## Use Cases

- Review a Go Pull Request: Find readability issues in control flow, declarations, function shape, and file organization before merging.
- Set Team Style Standards: Create a practical checklist for style decisions that are harder for automated linters to enforce.
- Guide AI Code Edits: Keep generated Go code readable when prompts ask for compact code, nested branches, or excessive parameters.

## Prompt Templates

### Review Basic Style

```
Review my Go file for readable style. Focus on line length, variable declarations, early returns, and initialized empty collections.
```

### Refactor One Function

```
Refactor this Go function for clarity. Preserve behavior, reduce nesting, remove unnecessary else blocks, and explain the style changes.
```

### Create Project Checklist

```
Create a concise Go code style checklist for this repository. Align it with existing patterns and note rules linters cannot enforce.
```

### Audit a Codebase

```
Review this Go codebase using separate style concerns. Report findings for control flow, function design, collection initialization, and file organization.
```

## Limitations

- It does not configure linters or replace gofmt, gofumpt, or goimports.
- It does not cover identifier naming, doc comments, or interface design in depth.
- It cannot prove performance claims without benchmarks from the target project.
- It may need project-specific conventions to resolve style tradeoffs.

## Best Practices

- Pair this skill with gofmt, gofumpt, and goimports for mechanical formatting.
- Ask for behavior-preserving edits before style refactors.
- Use repository conventions when they conflict with generic style guidance.

## Anti Patterns

- Using the skill to replace tests, linters, or compiler checks.
- Applying every guideline mechanically without considering readability.
- Requesting naming or documentation rules that belong to linked skills.

## Security Audit

- Audited at: 2026-07-06T20:47:58.628\+00:00
- Summary: Static alerts were reviewed in context and adjudicated as false positives. Backtick matches are Markdown code spans, fenced Go examples, and eval prompt strings rather than shell execution. The only URL is homepage metadata, and no prompt injection or malicious intent was found.

## Stats

- Views: 0
- Downloads: 6
- Favorites: 0
- Popularity score: 0
