Skip to content
Merged
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
5 changes: 3 additions & 2 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"owner": {
"name": "openshift-eng"
},
"allowCrossMarketplaceDependenciesOn": ["claude-plugins-official"],
"plugins": [
{
"name": "git",
Expand Down Expand Up @@ -211,8 +212,8 @@
{
"name": "golang",
"source": "./plugins/golang",
"description": "Run golang codebase related commands and tools",
"version": "0.1.0"
"description": "Go development tools: gopls MCP server, LSP integration, automatic gofmt formatting, and golangci-lint linting",
"version": "0.2.0"
},
{
"name": "ote-migration",
Expand Down
6 changes: 6 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"enabledPlugins": {
"plugin-dev@claude-plugins-official": true,
"skill-creator@claude-plugins-official": true
}
}
7 changes: 7 additions & 0 deletions .claudelint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ rules:
enabled: auto
severity: error

# MCP rules
mcp-prohibited:
enabled: true
severity: error
allowlist:
- gopls

# Skills rules
skill-frontmatter:
enabled: true
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ __pycache__/
venv/
*.egg

# Local settings
*.local.*

# Claude's settings for this repository
.claude/
.claude/*
!.claude/settings.json

# Working directories for skills
.work/
Expand Down
10 changes: 0 additions & 10 deletions PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ This document lists all available Claude Code plugins and their commands in the
- [Doc](#doc-plugin)
- [Etcd](#etcd-plugin)
- [Git](#git-plugin)
- [Golang](#golang-plugin)
- [Gwapi](#gwapi-plugin)
- [Hcp](#hcp-plugin)
- [Hello World](#hello-world-plugin)
Expand Down Expand Up @@ -162,15 +161,6 @@ Git workflow automation and utilities

See [plugins/git/README.md](plugins/git/README.md) for detailed documentation.

### Golang Plugin

Run golang codebase related commands and tools

**Commands:**
- **`/golang:lint-fix`** - Run golangci-lint tool and fix all reported issues

See [plugins/golang/README.md](plugins/golang/README.md) for detailed documentation.

### Gwapi Plugin

Gateway API management for Kubernetes/OpenShift clusters
Expand Down
26 changes: 15 additions & 11 deletions docs/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1692,26 +1692,30 @@
"version": "0.0.7"
},
{
"commands": [
"commands": [],
"description": "Go development tools: gopls MCP server, LSP integration, automatic gofmt formatting, and golangci-lint linting",
"has_readme": true,
"hooks": [
{
"argument_hint": "",
"description": "Run golangci-lint tool and fix all reported issues",
"name": "lint-fix",
"synopsis": "/golang:lint-fix"
"description": "Auto-format Go files with gofmt after write/edit",
"name": "PostToolUse",
"type": "PostToolUse"
}
],
"description": "Run golang codebase related commands and tools",
"has_readme": true,
"hooks": [],
"name": "golang",
"skills": [
{
"description": "Detect and run golangci-lint in a Go repository using the best available method",
"description": "Run golangci-lint to check Go code quality. Use when the user asks to lint, check for lint issues, or verify code quality in a Go project, or when linting is appropriate before committing Go code changes.",
"id": "lint",
"name": "Go Lint"
"name": "lint"
},
{
"description": "Run golangci-lint and fix all reported issues. Use only when explicitly asked to fix lint issues in a Go project.",
"id": "lint-fix",
"name": "lint-fix"
}
],
"version": "0.1.0"
"version": "0.2.0"
},
{
"commands": [
Expand Down
11 changes: 7 additions & 4 deletions plugins/golang/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"name": "golang",
"description": "Run golang codebase related commands and tools",
"version": "0.1.0",
"description": "Go development tools: gopls MCP server, LSP integration, automatic gofmt formatting, and golangci-lint linting",
"version": "0.2.0",
"author": {
"name": "github.com/openshift-eng"
}
}
},
"dependencies": [
{ "name": "gopls-lsp", "marketplace": "claude-plugins-official" }
]
}
8 changes: 8 additions & 0 deletions plugins/golang/.mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mcpServers": {
"gopls": {
"command": "gopls",
"args": ["mcp"]
}
}
}
83 changes: 32 additions & 51 deletions plugins/golang/README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,60 @@
# Golang Plugin

A Claude Code plugin for running [golangci-lint](https://golangci-lint.run/) to check and fix code quality issues in Go projects.

A Claude Code plugin for Go development, providing LSP integration via `gopls` and automatic `gofmt` formatting.

## Installation

```bash
/plugin install golang@ai-helpers
```

## Commands
## Features

| Command | Description |
|---------|-------------|
| `/golang:lint-fix` | Run golangci-lint and automatically fix all reported issues |
### gopls MCP Server

## Skills
Integrates the `gopls` language server as an MCP server, providing Go-aware code intelligence including go-to-definition, find references, hover documentation, and workspace symbols.

### Automatic gofmt Formatting

A PostToolUse hook automatically runs `gofmt -w -s` on any `.go` file after it is written or edited, keeping code consistently formatted without manual intervention.

### LSP Integration (via dependency)

| Skill | Description |
|-------|-------------|
| Go Lint | Detects and runs golangci-lint using the best available method for the repository. Loaded automatically when linting is relevant, and used by both commands above. |
Depends on the `gopls-lsp` plugin from `claude-plugins-official`, which enables LSP-based operations for Go code navigation and analysis.

## Prerequisites

- go compiler (available in $PATH)
- Go toolchain with `gopls` and `gofmt` available in `$PATH`
- `golangci-lint` available in `$PATH` (required by the `golang:lint` and `golang:lint-fix` skills)

- **Optional**: `make lint` target configured in Makefile, if not present the command will run `golangci-lint` directly.
Install `gopls` if not already present:

## Recommended Permissions
```bash
go install golang.org/x/tools/gopls@latest
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

To allow Claude Code to run the linter commands without prompting for approval, add the following to your project's `.claude/settings.json`:
Install `golangci-lint` if not already present:

```json
{
"permissions": {
"allow": [
"Bash(curl -s https://api.github.com/repos/golangci/golangci-lint/releases/latest)",
"Bash(make golangci-lint:*)",
"Bash(./bin/golangci-lint:*)",
"Bash(GOBIN=/tmp go install:*)",
"Bash(/tmp/golangci-lint:*)",
"Bash(make lint:*)",
"Bash(make lint)"
]
}
}
```bash
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
```

### What these permissions allow:
## Skills

### `golang:lint`

| Permission | Purpose |
|------------|---------|
| `curl ... golangci-lint/releases/latest` | Check for latest golangci-lint version |
| `make golangci-lint:*` | Run make targets for golangci-lint installation |
| `./bin/golangci-lint:*` | Run golangci-lint from project's bin directory |
| `GOBIN=/tmp go install:*` | Install golangci-lint to /tmp for temporary use |
| `/tmp/golangci-lint:*` | Run golangci-lint from /tmp |
| `make lint:*`, `make lint` | Run the standard `make lint` target |
Runs `golangci-lint` to check Go code quality. Discovers the lint command via CLAUDE.md/AGENTS.md, Makefile targets (`lint`, `verify-lint`), or direct `golangci-lint run ./...` invocation. Reports total issue count, breakdown by linter, and examples. Read-only — never modifies files.

## Usage
Invoked automatically when linting is appropriate (e.g., before committing Go changes), or on demand.

### `/golang:lint`: check for linter issues
### `golang:lint-fix`

This will:
1. Run golangci-lint using available methods (via the "Go Lint" skill)
2. Report total number of issues found
3. Summarize issues by category (goconst, gocyclo, staticcheck, etc.)
4. Show example issues
Runs `golangci-lint --fix` to auto-fix issues, then uses AI to resolve any remaining ones iteratively until the output is clean. Uses the same discovery cascade as `golang:lint`.

The "Go Lint" skill is also loaded automatically when the agent detects that linting is needed (e.g., the user says "run the linter" or "check for lint issues").
User-invocable only (`/golang:lint-fix`) — not triggered automatically due to its destructive nature.

### `/golang:lint-fix`: check for linter issues and fix them
## Dependencies

This will:
1. Run the "Go Lint" skill to identify all issues
2. Systematically fix each category of issues
3. Re-run linter after each fix to verify
4. Continue until all issues are resolved
| Plugin | Marketplace | Purpose |
|--------|-------------|---------|
| `gopls-lsp` | `claude-plugins-official` | LSP integration for Go code intelligence |
106 changes: 0 additions & 106 deletions plugins/golang/commands/lint-fix.md

This file was deleted.

29 changes: 29 additions & 0 deletions plugins/golang/hooks/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"description": "Auto-format Go files with gofmt after write/edit",
"hooks": {
"PostToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"if": "Write(**/*.go)",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/gofmt.sh",
"timeout": 10
}
]
},
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"if": "Edit(**/*.go)",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/gofmt.sh",
"timeout": 10
}
]
}
]
}
}
Loading