ktn-linter

module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT

README

KTN-Linter

Go Version

Personal Go linter enforcing strict programming standards beyond golangci-lint and staticcheck. 384 rules covering naming, structure, testing, performance, modern Go idioms, and staticcheck integration.

Strict rule: 0 issues = 0 issues (even INFO). STOP and fix immediately.

Installation

curl -sSL https://raw.githubusercontent.com/kodflow/ktn-linter/main/install.sh | bash

The script downloads the binary from GitHub releases (linux/darwin, amd64/arm64), installs to /usr/local/bin or ~/.local/bin, and optionally configures golangci-lint.

Installation from Source
git clone https://github.com/kodflow/ktn-linter
cd ktn-linter
make build

Usage

ktn-linter                                         # TTY: explore, non-TTY: lint ./...
ktn-linter lint ./...                              # Lint the entire project
ktn-linter lint --simple ./pkg/...                 # Simplified format
ktn-linter lint --config .ktn-linter.yaml ./...    # Use a config file
ktn-linter rules --format=markdown                 # Display all rules
ktn-linter explore ./...                           # Interactive directory browser with live file watching
ktn-linter coverage                                # Display per-package test coverage analysis
ktn-linter coverage --threshold 90                 # Custom threshold (default: 80%)
ktn-linter mcp install                             # Install MCP config + Claude Code hooks
ktn-linter skill install                           # Deploy embedded skills into ./.claude/
ktn-linter skill comments ./pkg                    # Refactor doc-comments via OAuth subscription
skill install

Deploys the bundle embedded in the binary (assets/) into <path>/.claude/: slash commands under commands/, agents under agents/, system prompts under prompts/. Files declared ktn-managed: true in their YAML frontmatter are silently replaced across versions; user-authored files at the same path are reported as conflicts and left untouched (--force overwrites them in place — rollback via git restore, no .bak sibling is written so .claude/ stays clean for git add .).

skill comments

Refactors every Go doc-comment under the target path to the canonical go.dev/doc/comment style (free prose, no Javadoc Params:/Returns: blocks).

  • Spawns the local claude CLI in print mode (NEVER --bare) so the user's OAuth subscription (Pro, Max, Team, Enterprise) is used. The preflight calls claude auth status and refuses to run unless authMethod == "claude.ai" and apiProvider == "firstParty". ANTHROPIC_API_KEY and other third-party billing variables are stripped from the spawned environment.
  • Runs inside a dedicated git worktree (.ktn-comments-<ts>); edits are squash-merged back into the original branch as one commit. Use --no-commit or --no-squash to opt out.
  • Preserves verbatim every comment block containing See: <repo>#<n> or a literal //ktn:keep line.
  • Keeps KTN-COMMENT-BLOCK //: intention markers; rewrites them only when phrasing is weak.

Configuration

KTN-Linter can be configured via .ktn-linter.yaml:

version: 1

# Skip non-KTN-TEST-* rules on Go test-variant packages (perf opt-in).
# Default: false. Set to true to lint *_test.go with the FULL rule set.
force_all_rules_on_tests: false

exclude:
  - "**/testdata/**"
  - "**/*_generated.go"
  - "vendor/**"

rules:
  KTN-FUNC-MAXSTMT:
    threshold: 50
  KTN-FUNC-CYCLO:
    threshold: 15
  KTN-COMMENT-LINELEN:
    enabled: false

Performance: test-variant skip. When packages.Load runs with Tests: true, the Go loader produces three synthetic test variants per package. By default the orchestrator only runs KTN-TEST-* rules on those variants — every other rule already executed on the production variant. Set force_all_rules_on_tests: true (or strict_mode: true) to lint test files with the full rule set.

Configurable thresholds:

Rule Parameter Default
KTN-COMMENT-LINELEN maxCommentLength 80
KTN-COMMENT-PKGDOC minPackageCommentLength 3
KTN-COMMENT-STRUCT minStructDocLines 2
KTN-FUNC-MAXSTMT maxFunctionLength 35
KTN-FUNC-MAXPARAM maxParameters 5
KTN-FUNC-NAKEDRET - (absolute rule) -
KTN-FUNC-CYCLO maxCyclomaticComplexity 8
KTN-FUNC-NAMERET maxNestedDepth 4
KTN-VAR-MAKEAPPEND maxScopeLines 50
KTN-VAR-HOTLOOP maxLineLength 120
KTN-VAR-GROUP maxDeclarations 10

Build & Test

Target Purpose
make build Compile ktn-linter to builds/ (Bazel)
make test Run all tests + coverage, generate COVERAGE.MD (Bazel)
make test-unit Unit tests only, cached (Bazel tag: unit)
make test-validate Testdata regression (always-run, Bazel tag: testdata)
make test-race Race condition detection (Bazel tag: race)
make test-bench Benchmark tests (Bazel tag: bench)
make coverage Coverage analysis per-package (Bazel)
make lint Runs KTN linter on itself (Bazel)

See COVERAGE.MD for detailed coverage report.

Rules (384 total)

KTN-API (1 rule)
Code Severity Description
KTN-API-MINIF WARNING Minimal interfaces on consumer side for external dependencies
KTN-COMMENT (8 rules)
Code Severity Description
KTN-COMMENT-LINELEN INFO Inline comments too long (>80 characters)
KTN-COMMENT-PKGDOC WARNING Descriptive comment before package
KTN-COMMENT-CONST WARNING Required comment for constants
KTN-COMMENT-VAR WARNING Required comment for package var
KTN-COMMENT-STRUCT WARNING Required documentation for struct (>=2 lines)
KTN-COMMENT-FUNC WARNING Function documentation (Params/Returns)
KTN-COMMENT-BLOCK WARNING Comments on branches/returns/logic
KTN-COMMENT-TODO INFO TODO/FIXME comment format (colon + description)
KTN-CONST (9 rules)
Code Severity Description
KTN-CONST-TYPED ERROR Explicit type required
KTN-CONST-ORDER INFO Grouping and placement before var
KTN-CONST-CAMEL INFO CamelCase naming (no underscores)
KTN-CONST-MINLEN WARNING Min length 2 characters
KTN-CONST-MAXLEN INFO Max length 30 characters
KTN-CONST-SHADOW INFO Must not shadow built-in identifiers
KTN-CONST-UNUSED WARNING Unused private constant
KTN-CONST-IOTA INFO Sequential constants should use iota
KTN-CONST-STRENUM INFO String enum should use int type with iota + String()
KTN-ERROR (4 rules)
Code Severity Description
KTN-ERROR-ASTYPE INFO Prefer errors.AsTypeT (Go 1.26+)
KTN-ERROR-CLOSECHECK WARNING Close/Shutdown/Stop error must be checked outside defer
KTN-ERROR-DEFERCLOSE WARNING defer Close/Shutdown/Stop must check returned error
KTN-ERROR-DISCARD WARNING Error assigned to _ must be logged or propagated
KTN-ERROR-SENTINEL WARNING errors.New() should be package-level sentinel
KTN-ERROR-WRAP WARNING fmt.Errorf() should wrap errors with %w
KTN-FUNC (23 rules)
Code Severity Description
KTN-FUNC-ERRLAST ERROR Error always in last return position
KTN-FUNC-CTXFIRST ERROR Context always as first parameter
KTN-FUNC-EARLYRET ERROR Avoid else after return/continue/break
KTN-FUNC-DEADCODE ERROR Unused private functions (dead code)
KTN-FUNC-CYCLO ERROR Max cyclomatic complexity 8
KTN-FUNC-MAXLOC ERROR Max 50 lines of code (LOC)
KTN-FUNC-MAXSTMT WARNING Max 35 statements per function
KTN-FUNC-MAXPARAM WARNING Max 5 parameters per function
KTN-FUNC-PUREGET WARNING No side effects in getters
KTN-FUNC-UNUSEDARG WARNING Unused parameters prefixed with _
KTN-FUNC-BLANKPARAM WARNING Blank _ in params must be interface-required
KTN-FUNC-NOMAGIC INFO No magic numbers (use named constants)
KTN-FUNC-NAKEDRET WARNING Naked returns forbidden when function has return values
KTN-FUNC-NAMEDPARAMS WARNING All function parameters and return values must be named
KTN-FUNC-NAMERET INFO Named returns for >3 return values
KTN-FUNC-GROUPARG INFO Group parameters of same type
KTN-FUNC-MINMAX INFO Prefer min/max builtins (Go 1.21+)
KTN-FUNC-USECLEAR INFO Use clear() builtin (Go 1.21+)
KTN-FUNC-RANGEINT INFO Use range N (Go 1.22+)
KTN-FUNC-ERRFMT INFO Error message format (lowercase, no period)
KTN-FUNC-NOINIT WARNING Avoid init() functions
KTN-FUNC-GENERICPTR INFO Use new(expr) instead of pointer wrapper functions (Go 1.26+)
KTN-FUNC-NILRETURN WARNING Return value always same constant (nil/true/false); consider removing
KTN-GENERIC (5 rules)
Code Severity Description
KTN-GENERIC-CMPEQ ERROR Comparable constraint required for == and !=
KTN-GENERIC-ORDERED ERROR cmp.Ordered constraint required for <, >, +, -, *, /, %
KTN-GENERIC-NOANY WARNING Unnecessary generics on interface types
KTN-GENERIC-USECMP WARNING golang.org/x/exp/constraints deprecated -> cmp
KTN-GENERIC-SHADOW WARNING Type params must not shadow predeclared identifiers
KTN-GOROUTINE (16 rules)
Code Severity Description
KTN-GOROUTINE-ATOMICBOOL INFO Mutex+bool replaceable by atomic.Bool
KTN-GOROUTINE-ATOMICINT INFO Mutex+int replaceable by atomic.Int64/Int32
KTN-GOROUTINE-ATOMICVAL INFO RWMutex+single field replaceable by atomic.Value
KTN-GOROUTINE-CTXCANCEL WARNING context.With*() without immediate defer cancel()
KTN-GOROUTINE-CTXDROP WARNING Func with ctx param calls context.Background()/TODO()
KTN-GOROUTINE-DEFER WARNING Immediate defer after resource acquisition
KTN-GOROUTINE-FIREFORGET WARNING Goroutine launched without synchronization
KTN-GOROUTINE-LIFECYCLE WARNING Missing goroutine documentation
KTN-GOROUTINE-LOCKSCOPE WARNING Unrelated statements inside critical section
KTN-GOROUTINE-ONCEINIT WARNING Lock+if !initialized replaceable by sync.Once
KTN-GOROUTINE-PTRRETURN WARNING Return pointer to mutex-protected field (data race)
KTN-GOROUTINE-RWOVERMU INFO Mutex.Lock() for read-only, use RWMutex.RLock()
KTN-GOROUTINE-SELECT WARNING Infinite loop goroutine without exit mechanism
KTN-GOROUTINE-SYNCMAP INFO RWMutex+map replaceable by sync.Map
KTN-GOROUTINE-SYNCMAPRACE WARNING sync.Map Load+Store race, use LoadOrStore
KTN-GOROUTINE-TIMEAFTER WARNING time.After() in select inside loop (timer leak)
KTN-INTERFACE (3 rules)
Code Severity Description
KTN-INTERFACE-UNUSED WARNING Unused private interface
KTN-INTERFACE-ERNAME INFO -er convention for single-method interfaces
KTN-INTERFACE-ANYUSE INFO Excessive use of interface{}/any
KTN-ITER (5 rules)
Code Severity Description
KTN-ITER-SIGNATURE INFO Invalid iterator signature
KTN-ITER-YIELD INFO Ignored yield return
KTN-ITER-MAPKEYS INFO Use maps.Keys/Values iterators
KTN-ITER-COLLECT INFO Use slices.Collect for iterators
KTN-ITER-PULLSTOP INFO iter.Pull must have defer stop()
KTN-RECEIVER (4 rules)
Code Severity Description
KTN-RECEIVER-MIXPTR ERROR Mixed receivers (pointer/value) on same type
KTN-RECEIVER-GENERIC WARNING Inconsistent generic receivers
KTN-RECEIVER-PTRMAP WARNING Unnecessary pointer to map/func/chan
KTN-RECEIVER-NAME INFO Receiver name 1-2 chars, not this/self/me
KTN-STRUCT (14 rules)
Code Severity Description
KTN-STRUCT-CTOR WARNING NewX() constructor required
KTN-STRUCT-NOGET WARNING No Get prefix for getters
KTN-STRUCT-RECVTYPE WARNING Receiver type consistency (pointer vs value)
KTN-STRUCT-RECVNAME WARNING Receiver name consistency (1-2 letters)
KTN-STRUCT-UNUSEDTYPE WARNING Unused private type
KTN-STRUCT-ACCESSOR INFO Getters/setters convention: Field() and SetField()
KTN-STRUCT-ONEFILE INFO One Go file per struct (DTOs can be grouped)
KTN-STRUCT-PUBFIRST INFO Exported fields before private fields
KTN-STRUCT-PRIVTAG INFO No serialization tags on private fields
KTN-STRUCT-JSONTAG INFO DTO exported fields must have json/xml tags
KTN-STRUCT-DTOTAG INFO DTO fields must have dto tag
KTN-STRUCT-FLATINIT INFO Use composite literal instead of individual field assignments
KTN-STRUCT-DEEPLIT INFO Extract deeply nested composite literals (>3 levels)
KTN-STRUCT-FLAGS INFO Struct with 3+ bool fields should use bitfield
KTN-SWITCH (2 rules)
Code Severity Description
KTN-SWITCH-EXHAUSTIVE WARNING Switch on enum types must cover all values
KTN-SWITCH-MERGECASE INFO Switch cases with identical body should be merged
KTN-TEST (29 rules)
Code Severity Description
KTN-TEST-SUFFIX ERROR Test files must end with _internal/_external_test.go
KTN-TEST-SETENV ERROR t.Setenv/t.Chdir forbidden with t.Parallel
KTN-TEST-HASGO WARNING Orphan test file (no source file)
KTN-TEST-COVERAGE WARNING Test coverage for public functions
KTN-TEST-TABLE WARNING Table-driven pattern required
KTN-TEST-NOSKIP WARNING t.Skip() forbidden
KTN-TEST-SPLIT WARNING 1:1 pattern for test/source files
KTN-TEST-EXTPUB WARNING Public tests only in _external_test.go
KTN-TEST-INTPRIV WARNING Private tests only in _internal_test.go
KTN-TEST-PKGNAME WARNING Package convention (white-box/black-box)
KTN-TEST-ASSERT WARNING Tests must contain assertions
KTN-TEST-ERRCASES WARNING Tests must cover error cases
KTN-TEST-SUBPARALLEL WARNING Subtests should have t.Parallel when parent does
KTN-TEST-CLEANUP WARNING Use t.Cleanup instead of defer with parallel subtests
KTN-TEST-IFACECHECK WARNING Interface checks must use compile-time pattern
KTN-TEST-PARALLEL WARNING Test functions must call t.Parallel()
KTN-TEST-CONSTCHECK INFO Test only verifies constant values
KTN-TEST-TMPDIR INFO Prefer t.TempDir() over os.TempDir()
KTN-TEST-CHDIR INFO Prefer t.Chdir() over os.Chdir()
KTN-TEST-TMPFILE INFO Use t.TempDir() in os.CreateTemp
KTN-TEST-MKDIR INFO Use t.TempDir() instead of os.MkdirTemp()
KTN-TEST-CASECNT INFO Number of cases vs cyclomatic complexity
KTN-TEST-PARALLELPOS INFO t.Parallel should be first statement
KTN-TEST-NOPARALLEL ERROR t.Parallel() forbidden with global state modification
KTN-TEST-OSENV WARNING Prefer t.Setenv() over os.Setenv()/os.Unsetenv()
KTN-TEST-FMTPRINT WARNING Prefer t.Log()/t.Logf() over fmt.Print*()
KTN-TEST-CONTEXT INFO Prefer t.Context() over context.Background()/TODO()
KTN-TEST-BLOOP INFO Prefer b.Loop() over legacy benchmark loop
KTN-TEST-SYNC WARNING 1:1 function-level sync between source and test files
KTN-TEST-NOOP ERROR No-op test only asserts on table fields, no SUT call
KTN-TEST-UNUSED-FIELDS WARNING Table struct fields never referenced in loop body
KTN-TEST-ASSERT-TRIVIAL WARNING Trivially-passing assertions (NotNil on string, True on true)
KTN-TEST-BRANCHCOV INFO Test has fewer assertions than function branches warrant
KTN-TEST-VOIDTEST WARNING Void function test missing side-effect verification
KTN-TEST-PLACEHOLDER WARNING Tests must call function under test
KTN-TEST-FILES WARNING Bidirectional source/test file correspondence
KTN-TEST-PLACEMENT WARNING Test functions in correct file type
KTN-VAR (63 rules)
Code Severity Description
KTN-VAR-CAMEL ERROR Required camelCase naming
KTN-VAR-SHADOW ERROR Variable shadowing detection
KTN-VAR-MUTEXCOPY ERROR Mutex copies (sync.Mutex, sync.RWMutex)
KTN-VAR-EXPLICIT WARNING Explicit type required for package var
KTN-VAR-ORDER WARNING Ordered declarations (const before var)
KTN-VAR-MINLEN WARNING Min variable length (scope-aware)
KTN-VAR-MAXLEN WARNING Max length 30 characters
KTN-VAR-HOTLOOP WARNING Avoid allocations in hot loops
KTN-VAR-RECVCONS WARNING Receiver consistency (pointer vs value)
KTN-VAR-PTRINTF WARNING Avoid pointer to interface
KTN-VAR-WEAKRAND WARNING crypto/rand for sensitive data
KTN-VAR-TYPEASSERT WARNING Unchecked type assertion (use comma-ok)
KTN-VAR-UNUSEDVAR WARNING Unused private package-level variable
KTN-VAR-REGEXPCOMPILE WARNING regexp.Compile inside function, move to package var
KTN-VAR-SHORTDECL INFO := vs var (zero-value aware)
KTN-VAR-BLANKASSIGN INFO x := f(); _ = x → use _ in := directly
KTN-VAR-DEADASSIGN INFO Dead blank assignment (_ = expr) is wasted computation
KTN-VAR-SLICECAP INFO Preallocate slices with known capacity
KTN-VAR-MAKEAPPEND INFO Avoid make([]T, length) with append
KTN-VAR-GROW INFO Preallocate bytes.Buffer with Grow
KTN-VAR-STRBUILDER INFO Use strings.Builder for concatenations
KTN-VAR-BIGSTRUCT INFO Pointers for structs >64 bytes as parameter
KTN-VAR-SYNCPOOL INFO sync.Pool for repeated buffers
KTN-VAR-STRCONV INFO Avoid repeated string() conversions
KTN-VAR-GROUP INFO Group in a single var() block
KTN-VAR-MAPCAP INFO Preallocate maps with known capacity
KTN-VAR-ARRAY INFO Use [N]T instead of make([]T, N) <=64 bytes
KTN-VAR-NILSLICE INFO Prefer nil slice to empty slice
KTN-VAR-USEANY INFO any vs interface{} (Go 1.18+)
KTN-VAR-USECLEAR INFO Use clear() built-in (Go 1.21+)
KTN-VAR-USEMINMAX INFO Use min()/max() built-in (Go 1.21+)
KTN-VAR-RANGEINT INFO range over integer (Go 1.22+)
KTN-VAR-LOOPVAR INFO Loop var copy obsolete (Go 1.22+)
KTN-VAR-SLICEGROW INFO slices.Grow instead of make+copy (Go 1.21+)
KTN-VAR-SLICECLONE INFO slices.Clone instead of make+copy (Go 1.21+)
KTN-VAR-MAPCLONE INFO maps.Clone instead of manual loop (Go 1.21+)
KTN-VAR-CMPOR INFO cmp.Or for default values (Go 1.22+)
KTN-VAR-WGGO INFO WaitGroup.Go (Go 1.25+)
KTN-VAR-CONTAINS INFO slices.Contains instead of loop (Go 1.21+)
KTN-VAR-INDEX INFO slices.Index instead of loop (Go 1.21+)
KTN-VAR-COLLECTKEYS INFO maps.Keys/Values iterators (Go 1.23+)
KTN-VAR-EXTRACTCONST INFO Extract repeated literals to constants
KTN-VAR-NEWEXPR INFO Use new(expr) instead of v := expr; &v (Go 1.26+)
KTN-VAR-PTRCALL INFO Use new(expr) instead of pointer helper calls (Go 1.26+)
KTN-VAR-CRYPTONIL INFO Pass nil to crypto APIs instead of rand.Reader (Go 1.26+)
KTN-VAR-UNCONVERT INFO Unnecessary type conversion (same source and target type)
KTN-VAR-DEFERPERF WARNING defer Close unnecessary, close immediately for performance
KTN-VAR-REFLECTITER INFO Use reflect Fields()/Methods() iterators (Go 1.26+)
KTN-VAR-FMTSPRINT INFO fmt.Sprintf replaceable by strconv.Itoa or direct use
KTN-VAR-ESCAPECLOSURE INFO Loop closure captures variable causing heap escape
KTN-VAR-NOESCAPE INFO &T{} in loop without escape, reuse variable
KTN-VAR-POINTERSTRUCT INFO Struct with pointer fields in large collection (GC scan)
KTN-VAR-SORTALLOC INFO sort.Slice → slices.SortFunc (Go 1.21+)
KTN-VAR-BYTESCONV INFO Repeated string([]byte) on same variable
KTN-VAR-STRINGCONCAT INFO String concatenation outside loop (use strings.Builder)
KTN-VAR-CONSTMAP WARNING Constant map literal in function body, hoist to package var
KTN-VAR-CONSTSLICE WARNING Constant slice literal in function body, hoist to package var
KTN-VAR-EQUALFOLD WARNING Use strings.EqualFold instead of ToLower/ToUpper comparison
KTN-VAR-TOLOWDUP WARNING Duplicate strings.ToLower/ToUpper on same variable
KTN-VAR-WALKDIR WARNING Use filepath.WalkDir instead of filepath.Walk (Go 1.16+)
KTN-VAR-CONSTABLE INFO Package var with constant value should be const
KTN-VAR-DEADSTORE WARNING Value assigned but never read before overwrite
KTN-VAR-TYPECONV INFO Redundant type conversion (source equals target type)
KTN-VAR-MATHBITS INFO Manual bit manipulation replaceable by math/bits
KTN-VAR-SPRINTF INFO fmt.Sprintf with single verb replaceable by strconv
KTN-VAR-NARROW INFO any parameter with single type assertion should be narrowed
KTN-VAR-STRMAP INFO map[string]T with constant keys, consider int-keyed map
KTN-GOVET (27 active / 28 total)

Official go vet analyzers wrapped with KTN-GOVET- prefix: appends, assign, atomic, bools, copylocks, defers, directive, errorsas, httpresponse, ifaceassert, loopclosure, lostcancel, nilfunc, printf, sigchanyzer, slog, sortslice, stdmethods, stringintconv, structtag, testinggoroutine, tests, timeformat, unmarshal, unreachable, unusedresult, waitgroup.

Disabled: shift (nil TypesInfo on external packages).

KTN-MODERNIZE (19 active / 20 total)

Official golang.org/x/tools modernize suite: appendassign, bloop, efaceany, fmtappendf, minmax, omitzero, rangeint, slicesclone, slicescontains, slicesdelete, slicesinsert, sortslice, stringbuilder, stringsseq, testingcontext, unsafefn, waitgroup, forvar, reflecttypefor.

Disabled: newexpr (nil pointer panic).

KTN-SC (160 active / 160 total)

All honnef.co/go/tools (staticcheck) analyzers wrapped with KTN-SC- prefix:

  • SA (95 rules): Correctness checks — invalid regexp, nil dereference, unused results, concurrency bugs
  • S (35 rules): Simplification — unnecessary code patterns, redundant operations
  • ST (18 rules): Style — naming conventions, package comments, error strings
  • QF (12 rules): Quick fixes — De Morgan's law, if/else to switch, redundant type declarations

Health Advisories

Post-lint meta-analysis that activates only when all lint violations are resolved (0 issues). Health checks operate on package metadata, not AST nodes.

Check Threshold Description
PKG-SIZE 20 files Packages with more than 20 non-test .go files

Health advisories appear as Phase 5 in ktn-linter prompt output and do not affect exit codes.

Statistics

Metric Value
Go version 1.26+
KTN rules 206
Go Vet rules 27
Modernize rules 20
Staticcheck rules 160
Total rules 423
Test coverage 99.4%
Packages at 100% 26/31

See COVERAGE.MD for detailed per-package metrics.

Directories

Path Synopsis
cmd
ktn-linter command
Package main provides the entry point for the ktn-linter CLI tool.
Package main provides the entry point for the ktn-linter CLI tool.
ktn-linter/cmd
Package cmd implements the CLI commands for ktn-linter.
Package cmd implements the CLI commands for ktn-linter.
pkg
analyzer/govet
Package govet wraps golang.org/x/tools go vet analyzers.
Package govet wraps golang.org/x/tools go vet analyzers.
analyzer/ktn
Package ktn provides the master registry for all KTN lint rules.
Package ktn provides the master registry for all KTN lint rules.
analyzer/ktn/api
Package api provides analyzers for API/dependency coupling rules.
Package api provides analyzers for API/dependency coupling rules.
analyzer/ktn/api/access
Package access provides analyzers for API access lint rules.
Package access provides analyzers for API access lint rules.
analyzer/ktn/comment
Package comment provides analyzers for comment formatting rules.
Package comment provides analyzers for comment formatting rules.
analyzer/ktn/comment/docs
Package docs provides analyzers for comment documentation lint rules.
Package docs provides analyzers for comment documentation lint rules.
analyzer/ktn/comment/format
Package format provides analyzers for comment formatting lint rules.
Package format provides analyzers for comment formatting lint rules.
analyzer/ktn/constant
Package constant provides analyzers for constant-related lint rules.
Package constant provides analyzers for constant-related lint rules.
analyzer/ktn/constant/naming
Package naming provides analyzers for constant naming lint rules.
Package naming provides analyzers for constant naming lint rules.
analyzer/ktn/constant/organization
Package organization provides analyzers for constant organization lint rules.
Package organization provides analyzers for constant organization lint rules.
analyzer/ktn/errs
Package errs provides analyzers for error handling rules.
Package errs provides analyzers for error handling rules.
analyzer/ktn/errs/assertion
Package assertion provides analyzers for error assertion lint rules.
Package assertion provides analyzers for error assertion lint rules.
analyzer/ktn/errs/handling
Package handling provides analyzers for error handling lint rules.
Package handling provides analyzers for error handling lint rules.
analyzer/ktn/function
Package function provides analyzers for function-related lint rules.
Package function provides analyzers for function-related lint rules.
analyzer/ktn/function/metrics
Package metrics provides analyzers for function metric lint rules.
Package metrics provides analyzers for function metric lint rules.
analyzer/ktn/function/parameters
Package parameters provides analyzers for function parameter lint rules.
Package parameters provides analyzers for function parameter lint rules.
analyzer/ktn/function/returns
Package returns provides analyzers for function return lint rules.
Package returns provides analyzers for function return lint rules.
analyzer/ktn/generic
Package generic provides analyzers for generic type lint rules.
Package generic provides analyzers for generic type lint rules.
analyzer/ktn/generic/constraint
Package constraint provides analyzers for generic constraint lint rules.
Package constraint provides analyzers for generic constraint lint rules.
analyzer/ktn/generic/typing
Package typing provides analyzers for generic type parameter lint rules.
Package typing provides analyzers for generic type parameter lint rules.
analyzer/ktn/goroutine
Package goroutine provides analyzers for goroutine-related lint rules.
Package goroutine provides analyzers for goroutine-related lint rules.
analyzer/ktn/goroutine/coordination
Package coordination provides analyzers for goroutine coordination lint rules.
Package coordination provides analyzers for goroutine coordination lint rules.
analyzer/ktn/goroutine/lockfree
Package lockfree provides analyzers for lock-free and mutex optimization rules.
Package lockfree provides analyzers for lock-free and mutex optimization rules.
analyzer/ktn/goroutine/resource
Package resource provides analyzers for goroutine resource management lint rules.
Package resource provides analyzers for goroutine resource management lint rules.
analyzer/ktn/goroutine/safety
Package safety provides analyzers for goroutine safety lint rules.
Package safety provides analyzers for goroutine safety lint rules.
analyzer/ktn/iface
Package iface provides analyzers for interface-related lint rules.
Package iface provides analyzers for interface-related lint rules.
analyzer/ktn/iface/compilecheck
Package compilecheck provides KTN-INTERFACE-COMPILE-CHECK.
Package compilecheck provides KTN-INTERFACE-COMPILE-CHECK.
analyzer/ktn/iface/naming
Package naming provides analyzers for interface naming lint rules.
Package naming provides analyzers for interface naming lint rules.
analyzer/ktn/iface/placement
Package placement provides analyzers for interface placement and filename conventions.
Package placement provides analyzers for interface placement and filename conventions.
analyzer/ktn/iface/returnconcrete
Package returnconcrete provides KTN-INTERFACE-RETURN-CONCRETE.
Package returnconcrete provides KTN-INTERFACE-RETURN-CONCRETE.
analyzer/ktn/iface/usage
Package usage provides analyzers for interface usage lint rules.
Package usage provides analyzers for interface usage lint rules.
analyzer/ktn/iterator
Package iterator provides analyzers for Go 1.23+ iterator lint rules.
Package iterator provides analyzers for Go 1.23+ iterator lint rules.
analyzer/ktn/iterator/contract
Package contract provides analyzers for iterator contract lint rules.
Package contract provides analyzers for iterator contract lint rules.
analyzer/ktn/iterator/patterns
Package patterns provides analyzers for iterator pattern lint rules.
Package patterns provides analyzers for iterator pattern lint rules.
analyzer/ktn/receiver
Package receiver provides analyzers for method receiver lint rules.
Package receiver provides analyzers for method receiver lint rules.
analyzer/ktn/receiver/consistency
Package consistency provides analyzers for receiver consistency lint rules.
Package consistency provides analyzers for receiver consistency lint rules.
analyzer/ktn/receiver/generics
Package generics provides analyzers for generic receiver lint rules.
Package generics provides analyzers for generic receiver lint rules.
analyzer/ktn/structure
Package structure provides analyzers for struct-related lint rules.
Package structure provides analyzers for struct-related lint rules.
analyzer/ktn/structure/dto
Package dto provides analyzers for struct DTO lint rules.
Package dto provides analyzers for struct DTO lint rules.
analyzer/ktn/structure/methods
Package methods provides analyzers for struct method lint rules.
Package methods provides analyzers for struct method lint rules.
analyzer/ktn/structure/organization
Package organization — KTN-STRUCT-CARGOPARAMS:
Package organization — KTN-STRUCT-CARGOPARAMS:
analyzer/ktn/switching
Package switching provides analyzers for switch statement rules.
Package switching provides analyzers for switch statement rules.
analyzer/ktn/switching/exhaustive
Package exhaustive provides analyzers for switch exhaustiveness lint rules.
Package exhaustive provides analyzers for switch exhaustiveness lint rules.
analyzer/ktn/switching/mergecase
Package mergecase provides an analyzer for detecting switch cases with identical bodies.
Package mergecase provides an analyzer for detecting switch cases with identical bodies.
analyzer/ktn/testhelper
Package testhelper implements KTN linter rules.
Package testhelper implements KTN linter rules.
analyzer/ktn/tests
Package tests provides analyzers for test file lint rules.
Package tests provides analyzers for test file lint rules.
analyzer/ktn/tests/classify
Package classify provides a test function classification analyzer.
Package classify provides a test function classification analyzer.
analyzer/ktn/tests/conventions
Package conventions provides analyzers for test convention lint rules.
Package conventions provides analyzers for test convention lint rules.
analyzer/ktn/tests/parallel
Package parallel provides analyzers for parallel test lint rules.
Package parallel provides analyzers for parallel test lint rules.
analyzer/ktn/tests/quality
Package quality provides analyzers for test quality lint rules.
Package quality provides analyzers for test quality lint rules.
analyzer/ktn/tests/testmeta
Package testmeta provides a shared test metadata extractor analyzer.
Package testmeta provides a shared test metadata extractor analyzer.
analyzer/ktn/variable
Package variable provides analyzers for variable-related lint rules.
Package variable provides analyzers for variable-related lint rules.
analyzer/ktn/variable/modern
Package modern provides analyzers for modern Go variable lint rules.
Package modern provides analyzers for modern Go variable lint rules.
analyzer/ktn/variable/naming
Package naming provides analyzers for variable naming lint rules.
Package naming provides analyzers for variable naming lint rules.
analyzer/ktn/variable/performance
Package performance provides analyzers for variable performance lint rules.
Package performance provides analyzers for variable performance lint rules.
analyzer/ktn/variable/safety
Package safety provides analyzers for variable safety lint rules.
Package safety provides analyzers for variable safety lint rules.
analyzer/modernize
Package modernize wraps golang.org/x/tools modernize analyzers.
Package modernize wraps golang.org/x/tools modernize analyzers.
analyzer/shared
Package shared — assertion_index.go:
Package shared — assertion_index.go:
analyzer/staticcheck
Package staticcheck wraps honnef.co/go/tools staticcheck analyzers.
Package staticcheck wraps honnef.co/go/tools staticcheck analyzers.
analyzer/utils
Package utils provides AST utility functions for analyzers.
Package utils provides AST utility functions for analyzers.
cache
Package cache provides content-addressable cache key composition, file/buffer pooling, and rule scope metadata used by the linter orchestrator and MCP serve engine.
Package cache provides content-addressable cache key composition, file/buffer pooling, and rule scope metadata used by the linter orchestrator and MCP serve engine.
claudecli
Package claudecli — auth state parsed from `claude auth status`.
Package claudecli — auth state parsed from `claude auth status`.
config
Package config provides configuration management for KTN linter rules.
Package config provides configuration management for KTN linter rules.
cover
Package cover provides Go-compatible statement block counting for coverage analysis.
Package cover provides Go-compatible statement block counting for coverage analysis.
coverage/eval
Package eval provides test recognition, outcome matching, and confidence scoring.
Package eval provides test recognition, outcome matching, and confidence scoring.
coverage/ir
Package ir extracts control flow decisions from Go AST.
Package ir extracts control flow decisions from Go AST.
coverage/model
Package model defines domain types for the static decision analysis engine.
Package model defines domain types for the static decision analysis engine.
coverage/report
Package report provides CLI output formatting for decision analysis results.
Package report provides CLI output formatting for decision analysis results.
coverage/runtime
Package runtime provides targeted go test execution with coverage profile parsing.
Package runtime provides targeted go test execution with coverage profile parsing.
coverage/scenario
Package scenario provides partition-based scenario coverage analysis.
Package scenario provides partition-based scenario coverage analysis.
exit
Package exit provides structured process exit with full traceability.
Package exit provides structured process exit with full traceability.
exit/code
Package code defines structured exit code constants for ktn-linter.
Package code defines structured exit code constants for ktn-linter.
explore
Package explore provides an interactive directory browser for ktn-linter violations.
Package explore provides an interactive directory browser for ktn-linter violations.
formatter
Package formatter provides output formatting for lint diagnostics.
Package formatter provides output formatting for lint diagnostics.
health
Package health provides post-lint meta-analysis for structural health advisories.
Package health provides post-lint meta-analysis for structural health advisories.
messages
Package messages provides structured error messages for KTN rules.
Package messages provides structured error messages for KTN rules.
orchestrator
Package orchestrator coordinates the linting pipeline.
Package orchestrator coordinates the linting pipeline.
prompt
Package prompt provides AI-optimized prompt generation for KTN linter violations.
Package prompt provides AI-optimized prompt generation for KTN linter violations.
refactor
Package refactor provides language-agnostic refactor tooling: public-API snapshots, diffing, and cross-package caller search.
Package refactor provides language-agnostic refactor tooling: public-API snapshots, diffing, and cross-package caller search.
rules
Package rules provides rule information extraction and formatting utilities.
Package rules provides rule information extraction and formatting utilities.
serve
Package serve provides a persistent MCP server with HTTP API and file watching for real-time linting diagnostics.
Package serve provides a persistent MCP server with HTTP API and file watching for real-time linting diagnostics.
severity
Package severity defines severity levels for lint rules.
Package severity defines severity levels for lint rules.
skills
Package skills — helpers that translate the embedded agent .md files into the JSON object accepted by `claude --agents`.
Package skills — helpers that translate the embedded agent .md files into the JSON object accepted by `claude --agents`.
tui
Package tui provides a terminal user interface for ktn-linter analysis progress.
Package tui provides a terminal user interface for ktn-linter analysis progress.
ui
Package ui provides a shared theme, styles, and reusable components for all terminal rendering in ktn-linter.
Package ui provides a shared theme, styles, and reusable components for all terminal rendering in ktn-linter.
updater
Package updater provides self-update functionality for ktn-linter binary.
Package updater provides self-update functionality for ktn-linter binary.
worktree
Package worktree — see worktree.go for the package overview.
Package worktree — see worktree.go for the package overview.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL