Add Linter Rule to attgo-linter

VerifiedSafe

Guides the creation and integration of new linter rules into attgo-linter. It covers gathering rule specifications, generating analyzer packages, registering the rule in plugin and config files, and updating documentation. Useful for contributors extending the linter's capabilities.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#go#linter#analysis#rule-creation#static-analysis

Recommended for

Automated summary

This skill guides the addition of a new linting rule to the attgo-linter project, following a structured procedure.

Strengths

  • Clear step-by-step instructions with ready-to-use templates
  • Includes creation of tests and test fixtures
  • Comprehensive checklist to ensure nothing is missed
  • Automates registration in the plugin and configuration files

Limitations

  • Specific to the attgo-linter project and its Go analysis framework
  • Requires prior knowledge of static analysis in Go
  • Does not handle advanced custom rules or input validation
When to use it

When you need to add a new linting rule to the attgo-linter project, including all associated files, tests, and documentation.

When not to use it

For a different linting project or if you want to modify an existing rule instead of creating a new one.

Security analysis

Safe
Quality score92/100

The skill instructs adding linter rules via standard file creation, code edits, and running 'go test'. No destructive, exfiltrating, or obfuscated commands are present.

No concerns found

How this analysis is made

Examples

Add a no-global-vars rule
Add a new linter rule called 'no-global-vars' that warns about global variable declarations, with priority HIGH. Provide a bad example with a global var and a good example using local variables. Include configuration to allow a whitelist of package-level constants.
Add a forbid-println rule
Create a linting rule named 'forbid-println' that flags calls to fmt.Println and log.Println. Priority MEDIUM. Bad example: fmt.Println("hello"). Good example: using a structured logger. Include test fixtures and documentation.

Add Rule Skill

This skill helps you add new rules to the attgo-linter project.

Usage

When asked to add a new linter rule, follow these steps:

1. Gather Information

Ask the user for:

  • Rule name: e.g., "no-global-vars"
  • Description: What the rule checks
  • Priority: HIGH (enabled by default), MEDIUM, or LOW (disabled by default)
  • Bad example: Code that should trigger the warning
  • Good example: Code that passes the check
  • Configuration options: Any customizable settings

2. Create Analyzer Package

Create the following files:

analyzers/{rulename}/
├── analyzer.go
└── analyzer_test.go

The analyzer name must use underscores (not hyphens): attgo_{rule_name}

3. Create Test Fixtures

analyzers/{rulename}/testdata/src/{rulename}/
└── {rulename}.go

Use // want \regex pattern`` comments for expected diagnostics.

4. Register in Plugin

Update plugin.go:

  • Add import
  • Add to BuildAnalyzers() with config check

Update config.go:

  • Add Enable{RuleName} field to Config struct
  • Set default in DefaultConfig()

Update plugin.go config handling:

  • Add explicit check for the setting in New()

5. Update Documentation

  • Add rule section to README.md
  • Create docs/rules/attgo-{rule-name}.md
  • Update CHANGELOG.md

6. Verify

Run tests:

go test ./...

Template: analyzer.go

// Copyright © 2026 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// ...

// Package {rulename} provides an analyzer that {description}.
package {rulename}

import (
    "golang.org/x/tools/go/analysis"
)

const (
    analyzerName = "attgo_{rule_name}"
    doc          = `{short description}

{detailed explanation}

Bad:
    {bad example}

Good:
    {good example}`
)

// Analyzer is the {description} analyzer.
var Analyzer = &analysis.Analyzer{
    Name: analyzerName,
    Doc:  doc,
    Run:  run,
}

func run(pass *analysis.Pass) (any, error) {
    for _, file := range pass.Files {
        // Implementation
    }
    return nil, nil
}

Template: analyzer_test.go

// Copyright © 2025 Attestant Limited.
// ...

package {rulename}_test

import (
    "testing"

    "github.com/attestantio/attgo-linter/analyzers/{rulename}"
    "golang.org/x/tools/go/analysis/analysistest"
)

func TestAnalyzer(t *testing.T) {
    testdata := analysistest.TestData()
    analysistest.Run(t, testdata, {rulename}.Analyzer, "{rulename}")
}

Template: testdata

// Copyright © 2025 Attestant Limited.
// ...

package {rulename}

// Bad case.
var bad = something // want `expected error`

// Good case.
var good = something // No warning

Checklist

  • [ ] Created analyzers/{rulename}/analyzer.go
  • [ ] Created analyzers/{rulename}/analyzer_test.go
  • [ ] Created analyzers/{rulename}/testdata/src/{rulename}/{rulename}.go
  • [ ] Added import to plugin.go
  • [ ] Added to BuildAnalyzers() in plugin.go
  • [ ] Added config field to config.go
  • [ ] Added default value in DefaultConfig()
  • [ ] Added config handling in New()
  • [ ] Tests pass: go test ./...
  • [ ] Added documentation to README.md
  • [ ] Updated CHANGELOG.md

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/add-linter-rule-to-attgo-linter-mm5t89z3/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/add-linter-rule-to-attgo-linter-mm5t89z3' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/add-linter-rule-to-attgo-linter-mm5t89z3/download' --output '.skill-downloads/add-linter-rule-to-attgo-linter-mm5t89z3/SKILL.md.part' && mv '.skill-downloads/add-linter-rule-to-attgo-linter-mm5t89z3/SKILL.md.part' '.skill-downloads/add-linter-rule-to-attgo-linter-mm5t89z3/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/add-linter-rule-to-attgo-linter-mm5t89z3/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills