Documentation
¶
Index ¶
- Variables
- func BuildFileList(paths []string) string
- func ExtractJSON(s string) string
- func FilteredFilePaths(nodes []*analyzer.ConfigNode, minContentSize int) []string
- func ScopeContextDescription(scope *analyzer.ContextScope) string
- func TruncateForError(s string) string
- type AnalysisContext
- func (ctx *AnalysisContext) AllFiles() []*analyzer.ConfigNode
- func (ctx *AnalysisContext) FileByPath(path string) *analyzer.ConfigNode
- func (ctx *AnalysisContext) FilesMatching(predicate func(*analyzer.ConfigNode) bool) []*analyzer.ConfigNode
- func (ctx *AnalysisContext) FilesOfType(categories ...parser.FileCategory) []*analyzer.ConfigNode
- func (ctx *AnalysisContext) FilesWithContent() []*analyzer.ConfigNode
- func (ctx *AnalysisContext) Scopes() ([]*analyzer.ContextScope, error)
- type BroadPermissionsRule
- type BrokenRefsRule
- type CircularRefsRule
- type ContradictionsRule
- type DuplicateInstructionsRule
- type Edit
- type Fix
- type Issue
- type LLMActionabilityRule
- type LLMAnalysisRule
- type LLMClarityRule
- type LLMContradictionsRule
- type LLMDuplicatesRule
- type LLMIssue
- type LLMResponse
- type LLMRuleBase
- type LongDocumentRule
- type MissingContextRule
- type MissingEntrypointRule
- type MissingSkillRule
- type MissingToolRule
- type Registry
- type Rule
- type RuleConfig
- type ScopeAnalyzeFunc
- type Severity
- type VagueInstructionsRule
- type VerbosityRule
Constants ¶
This section is empty.
Variables ¶
var ClaudeBuiltinTools = map[string]bool{ "Read": true, "Write": true, "Edit": true, "Bash": true, "Glob": true, "Grep": true, "Task": true, "WebFetch": true, "WebSearch": true, "TodoWrite": true, "NotebookEdit": true, "AskUserQuestion": true, "Skill": true, "EnterPlanMode": true, "ExitPlanMode": true, "KillShell": true, "TaskOutput": true, }
ClaudeBuiltinTools is the set of known Claude Code built-in tools
Functions ¶
func BuildFileList ¶
BuildFileList formats a list of file paths for inclusion in an LLM prompt
func ExtractJSON ¶
ExtractJSON attempts to extract JSON from a response that might be wrapped in markdown
func FilteredFilePaths ¶
func FilteredFilePaths(nodes []*analyzer.ConfigNode, minContentSize int) []string
FilteredFilePaths returns file paths from nodes, optionally filtering by minimum content size
func ScopeContextDescription ¶
func ScopeContextDescription(scope *analyzer.ContextScope) string
ScopeContextDescription returns a human-readable description of the scope
func TruncateForError ¶
TruncateForError truncates a string for inclusion in error messages
Types ¶
type AnalysisContext ¶
AnalysisContext provides context for rule analysis
func (*AnalysisContext) AllFiles ¶
func (ctx *AnalysisContext) AllFiles() []*analyzer.ConfigNode
AllFiles returns all ConfigNodes in the tree.
func (*AnalysisContext) FileByPath ¶
func (ctx *AnalysisContext) FileByPath(path string) *analyzer.ConfigNode
FileByPath returns the ConfigNode for a specific path, or nil if not found.
func (*AnalysisContext) FilesMatching ¶
func (ctx *AnalysisContext) FilesMatching(predicate func(*analyzer.ConfigNode) bool) []*analyzer.ConfigNode
FilesMatching returns all ConfigNodes matching the predicate.
func (*AnalysisContext) FilesOfType ¶
func (ctx *AnalysisContext) FilesOfType(categories ...parser.FileCategory) []*analyzer.ConfigNode
FilesOfType returns all ConfigNodes matching the given categories. If no categories are provided, returns all files.
func (*AnalysisContext) FilesWithContent ¶
func (ctx *AnalysisContext) FilesWithContent() []*analyzer.ConfigNode
FilesWithContent returns all ConfigNodes that have non-empty content.
func (*AnalysisContext) Scopes ¶
func (ctx *AnalysisContext) Scopes() ([]*analyzer.ContextScope, error)
Scopes returns all context scopes discovered in the tree.
type BroadPermissionsRule ¶
type BroadPermissionsRule struct{}
BroadPermissionsRule checks for overly broad permission configurations
func (*BroadPermissionsRule) Config ¶
func (r *BroadPermissionsRule) Config() RuleConfig
func (*BroadPermissionsRule) Description ¶
func (r *BroadPermissionsRule) Description() string
func (*BroadPermissionsRule) Name ¶
func (r *BroadPermissionsRule) Name() string
func (*BroadPermissionsRule) Run ¶
func (r *BroadPermissionsRule) Run(ctx *AnalysisContext) ([]Issue, error)
type BrokenRefsRule ¶
type BrokenRefsRule struct{}
BrokenRefsRule checks for broken file and URL references
func (*BrokenRefsRule) Config ¶
func (r *BrokenRefsRule) Config() RuleConfig
func (*BrokenRefsRule) Description ¶
func (r *BrokenRefsRule) Description() string
func (*BrokenRefsRule) Name ¶
func (r *BrokenRefsRule) Name() string
func (*BrokenRefsRule) Run ¶
func (r *BrokenRefsRule) Run(ctx *AnalysisContext) ([]Issue, error)
type CircularRefsRule ¶
type CircularRefsRule struct{}
CircularRefsRule checks for circular references in the configuration tree
func (*CircularRefsRule) Config ¶
func (r *CircularRefsRule) Config() RuleConfig
func (*CircularRefsRule) Description ¶
func (r *CircularRefsRule) Description() string
func (*CircularRefsRule) Name ¶
func (r *CircularRefsRule) Name() string
func (*CircularRefsRule) Run ¶
func (r *CircularRefsRule) Run(ctx *AnalysisContext) ([]Issue, error)
type ContradictionsRule ¶
type ContradictionsRule struct{}
ContradictionsRule checks for potential contradictions in instructions
func (*ContradictionsRule) Config ¶
func (r *ContradictionsRule) Config() RuleConfig
func (*ContradictionsRule) Description ¶
func (r *ContradictionsRule) Description() string
func (*ContradictionsRule) Name ¶
func (r *ContradictionsRule) Name() string
func (*ContradictionsRule) Run ¶
func (r *ContradictionsRule) Run(ctx *AnalysisContext) ([]Issue, error)
type DuplicateInstructionsRule ¶
type DuplicateInstructionsRule struct{}
DuplicateInstructionsRule checks for duplicate or near-duplicate instructions
func (*DuplicateInstructionsRule) Config ¶
func (r *DuplicateInstructionsRule) Config() RuleConfig
func (*DuplicateInstructionsRule) Description ¶
func (r *DuplicateInstructionsRule) Description() string
func (*DuplicateInstructionsRule) Name ¶
func (r *DuplicateInstructionsRule) Name() string
func (*DuplicateInstructionsRule) Run ¶
func (r *DuplicateInstructionsRule) Run(ctx *AnalysisContext) ([]Issue, error)
type Issue ¶
type Issue struct {
Rule string
Severity Severity
Message string
File string
Line int
Column int
EndLine int
Context string
Fix *Fix
}
Issue represents a linting issue
func RunPerScope ¶
func RunPerScope(ctx *AnalysisContext, categories []parser.FileCategory, analyze ScopeAnalyzeFunc) ([]Issue, error)
RunPerScope discovers all context scopes and runs the analysis function for each. This allows LLM rules to operate on isolated scopes without needing to know about scope boundaries themselves.
type LLMActionabilityRule ¶
type LLMActionabilityRule struct {
// contains filtered or unexported fields
}
LLMActionabilityRule detects instructions with low actionability using LLM analysis
func NewLLMActionabilityRule ¶
func NewLLMActionabilityRule() *LLMActionabilityRule
NewLLMActionabilityRule creates a new LLM actionability rule. Returns nil if Claude Code CLI is not available.
func (*LLMActionabilityRule) Config ¶
func (r *LLMActionabilityRule) Config() RuleConfig
func (*LLMActionabilityRule) Description ¶
func (r *LLMActionabilityRule) Description() string
func (*LLMActionabilityRule) Name ¶
func (r *LLMActionabilityRule) Name() string
func (*LLMActionabilityRule) Run ¶
func (r *LLMActionabilityRule) Run(ctx *AnalysisContext) ([]Issue, error)
type LLMAnalysisRule ¶
type LLMAnalysisRule struct {
// contains filtered or unexported fields
}
LLMAnalysisRule uses Claude Code for deep configuration analysis
func NewLLMAnalysisRule ¶
func NewLLMAnalysisRule() *LLMAnalysisRule
NewLLMAnalysisRule creates a new LLM analysis rule. Returns nil if Claude Code CLI is not available.
func (*LLMAnalysisRule) Config ¶
func (r *LLMAnalysisRule) Config() RuleConfig
func (*LLMAnalysisRule) Description ¶
func (r *LLMAnalysisRule) Description() string
func (*LLMAnalysisRule) Name ¶
func (r *LLMAnalysisRule) Name() string
func (*LLMAnalysisRule) Run ¶
func (r *LLMAnalysisRule) Run(ctx *AnalysisContext) ([]Issue, error)
type LLMClarityRule ¶
type LLMClarityRule struct {
// contains filtered or unexported fields
}
LLMClarityRule detects unclear or vague instructions using LLM analysis
func NewLLMClarityRule ¶
func NewLLMClarityRule() *LLMClarityRule
NewLLMClarityRule creates a new LLM clarity rule. Returns nil if Claude Code CLI is not available.
func (*LLMClarityRule) Config ¶
func (r *LLMClarityRule) Config() RuleConfig
func (*LLMClarityRule) Description ¶
func (r *LLMClarityRule) Description() string
func (*LLMClarityRule) Name ¶
func (r *LLMClarityRule) Name() string
func (*LLMClarityRule) Run ¶
func (r *LLMClarityRule) Run(ctx *AnalysisContext) ([]Issue, error)
type LLMContradictionsRule ¶
type LLMContradictionsRule struct {
// contains filtered or unexported fields
}
LLMContradictionsRule detects contradicting instructions using LLM analysis
func NewLLMContradictionsRule ¶
func NewLLMContradictionsRule() *LLMContradictionsRule
NewLLMContradictionsRule creates a new LLM contradictions rule. Returns nil if Claude Code CLI is not available.
func (*LLMContradictionsRule) Config ¶
func (r *LLMContradictionsRule) Config() RuleConfig
func (*LLMContradictionsRule) Description ¶
func (r *LLMContradictionsRule) Description() string
func (*LLMContradictionsRule) Name ¶
func (r *LLMContradictionsRule) Name() string
func (*LLMContradictionsRule) Run ¶
func (r *LLMContradictionsRule) Run(ctx *AnalysisContext) ([]Issue, error)
type LLMDuplicatesRule ¶
type LLMDuplicatesRule struct {
// contains filtered or unexported fields
}
LLMDuplicatesRule detects duplicate or near-duplicate instructions using LLM analysis
func NewLLMDuplicatesRule ¶
func NewLLMDuplicatesRule() *LLMDuplicatesRule
NewLLMDuplicatesRule creates a new LLM duplicates rule. Returns nil if Claude Code CLI is not available.
func (*LLMDuplicatesRule) Config ¶
func (r *LLMDuplicatesRule) Config() RuleConfig
func (*LLMDuplicatesRule) Description ¶
func (r *LLMDuplicatesRule) Description() string
func (*LLMDuplicatesRule) Name ¶
func (r *LLMDuplicatesRule) Name() string
func (*LLMDuplicatesRule) Run ¶
func (r *LLMDuplicatesRule) Run(ctx *AnalysisContext) ([]Issue, error)
type LLMIssue ¶
type LLMIssue struct {
File string `json:"file"`
Line int `json:"line"`
Severity string `json:"severity"`
Message string `json:"message"`
Suggestion string `json:"suggestion,omitempty"`
}
LLMIssue represents an issue from LLM analysis
type LLMResponse ¶
type LLMResponse struct {
Issues []LLMIssue `json:"issues"`
}
LLMResponse is the common response structure from LLM rules
func (*LLMResponse) ToRuleIssues ¶
func (r *LLMResponse) ToRuleIssues(ruleName string, defaultFile string) []Issue
ToRuleIssues converts LLM issues to rule issues
type LLMRuleBase ¶
type LLMRuleBase struct {
// contains filtered or unexported fields
}
LLMRuleBase provides shared functionality for LLM-based rules
func NewLLMRuleBase ¶
func NewLLMRuleBase() *LLMRuleBase
NewLLMRuleBase creates a new LLMRuleBase, checking if Claude Code is available. Returns nil if the CLI is not found.
func (*LLMRuleBase) CheckAvailable ¶
func (b *LLMRuleBase) CheckAvailable() error
CheckAvailable returns an error if the rule cannot run
func (*LLMRuleBase) ExecuteQuery ¶
ExecuteQuery runs a query against Claude Code and returns the response text
func (*LLMRuleBase) IsAvailable ¶
func (b *LLMRuleBase) IsAvailable() bool
IsAvailable returns whether the LLM rule can run
type LongDocumentRule ¶
LongDocumentRule checks for overly long configuration documents
func (*LongDocumentRule) Config ¶
func (r *LongDocumentRule) Config() RuleConfig
func (*LongDocumentRule) Description ¶
func (r *LongDocumentRule) Description() string
func (*LongDocumentRule) Name ¶
func (r *LongDocumentRule) Name() string
func (*LongDocumentRule) Run ¶
func (r *LongDocumentRule) Run(ctx *AnalysisContext) ([]Issue, error)
type MissingContextRule ¶
type MissingContextRule struct{}
MissingContextRule checks for instructions that lack supporting context
func (*MissingContextRule) Config ¶
func (r *MissingContextRule) Config() RuleConfig
func (*MissingContextRule) Description ¶
func (r *MissingContextRule) Description() string
func (*MissingContextRule) Name ¶
func (r *MissingContextRule) Name() string
func (*MissingContextRule) Run ¶
func (r *MissingContextRule) Run(ctx *AnalysisContext) ([]Issue, error)
type MissingEntrypointRule ¶
type MissingEntrypointRule struct{}
MissingEntrypointRule checks for missing primary configuration files
func (*MissingEntrypointRule) Config ¶
func (r *MissingEntrypointRule) Config() RuleConfig
func (*MissingEntrypointRule) Description ¶
func (r *MissingEntrypointRule) Description() string
func (*MissingEntrypointRule) Name ¶
func (r *MissingEntrypointRule) Name() string
func (*MissingEntrypointRule) Run ¶
func (r *MissingEntrypointRule) Run(ctx *AnalysisContext) ([]Issue, error)
type MissingSkillRule ¶
type MissingSkillRule struct{}
MissingSkillRule checks that skills declared in frontmatter exist in the project
func (*MissingSkillRule) Config ¶
func (r *MissingSkillRule) Config() RuleConfig
func (*MissingSkillRule) Description ¶
func (r *MissingSkillRule) Description() string
func (*MissingSkillRule) Name ¶
func (r *MissingSkillRule) Name() string
func (*MissingSkillRule) Run ¶
func (r *MissingSkillRule) Run(ctx *AnalysisContext) ([]Issue, error)
type MissingToolRule ¶
type MissingToolRule struct{}
MissingToolRule checks that tools declared in frontmatter exist
func (*MissingToolRule) Config ¶
func (r *MissingToolRule) Config() RuleConfig
func (*MissingToolRule) Description ¶
func (r *MissingToolRule) Description() string
func (*MissingToolRule) Name ¶
func (r *MissingToolRule) Name() string
func (*MissingToolRule) Run ¶
func (r *MissingToolRule) Run(ctx *AnalysisContext) ([]Issue, error)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered rules
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry returns a registry with all default rules
type Rule ¶
type Rule interface {
// Name returns the unique identifier for this rule
Name() string
// Description returns a human-readable description
Description() string
// Config returns the rule's configuration
Config() RuleConfig
// Run executes the rule and returns any issues found.
// AI rules may return errors for API failures; regular rules typically return nil error.
Run(ctx *AnalysisContext) ([]Issue, error)
}
Rule defines the interface for lint rules
type RuleConfig ¶
type RuleConfig struct {
// FileCategories specifies which file types this rule applies to.
// Empty slice means all file types.
FileCategories []parser.FileCategory
// RequiresAI indicates this rule needs AI/LLM for analysis.
// AI rules only run when --deep flag is enabled.
RequiresAI bool
}
RuleConfig defines how a rule should be invoked
type ScopeAnalyzeFunc ¶
type ScopeAnalyzeFunc func(scope *analyzer.ContextScope, files []*analyzer.ConfigNode) ([]Issue, error)
ScopeAnalyzeFunc is a function that analyzes a single context scope
type VagueInstructionsRule ¶
type VagueInstructionsRule struct{}
VagueInstructionsRule checks for vague or unclear instructions
func (*VagueInstructionsRule) Config ¶
func (r *VagueInstructionsRule) Config() RuleConfig
func (*VagueInstructionsRule) Description ¶
func (r *VagueInstructionsRule) Description() string
func (*VagueInstructionsRule) Name ¶
func (r *VagueInstructionsRule) Name() string
func (*VagueInstructionsRule) Run ¶
func (r *VagueInstructionsRule) Run(ctx *AnalysisContext) ([]Issue, error)
type VerbosityRule ¶
type VerbosityRule struct{}
VerbosityRule checks for overly verbose or low-density instructions
func (*VerbosityRule) Config ¶
func (r *VerbosityRule) Config() RuleConfig
func (*VerbosityRule) Description ¶
func (r *VerbosityRule) Description() string
func (*VerbosityRule) Name ¶
func (r *VerbosityRule) Name() string
func (*VerbosityRule) Run ¶
func (r *VerbosityRule) Run(ctx *AnalysisContext) ([]Issue, error)
Source Files
¶
- broad_permissions.go
- broken_refs.go
- circular_refs.go
- contradictions.go
- duplicate_instructions.go
- llm_actionability.go
- llm_analysis.go
- llm_base.go
- llm_clarity.go
- llm_contradictions.go
- llm_duplicates.go
- long_document.go
- missing_context.go
- missing_entrypoint.go
- missing_skill.go
- missing_tool.go
- registry.go
- rule.go
- scoped_runner.go
- vague_instructions.go
- verbosity.go