agnix Agent Config Linter

repository·main·Indexed 43 days ago

https://github.com/agent-sh/agnix

An Agent Config Linter designed to catch syntax errors and bad patterns in AI agent configuration files, including CLAUDE.md, SKILL.md, MCP configs, and Cursor rules. It provides a CLI (agnix-cli), a core library (agnix-core), and a language server (agnix-lsp) with support for VS Code, Zed, Neovim, Helix, and JetBrains IDEs.

Tokens
191.9K
Snippets
477
Records
815
Agent score
54%

What's inside agnix

  1. What is agnix?

    main
    agnix is a linter specifically designed for AI agent configuration files. It validates various components such as Skills, Hooks, Memory, Plugins, and MCP (Model Context Protocol) configurations across multiple AI agent platforms, including Claude Code, Cursor, GitHub Copilot, and Codex CLI. It provides validation against 456 rules, supports auto-fixing, and integrates with modern editors via LSP.
  2. Navigate the AI Agent Knowledge Library

    main

    The AI Agent Knowledge Library serves as a curated entrypoint to internal standards, validation rules, and authoritative external sources for building and configuring AI agents. Use the following resources to implement and maintain agent standards:

    • Implementation & Validation: Refer to VALIDATION-RULES.md for rules and standards/ for hard rules and opinions.
    • Design Patterns: Use PATTERNS-CATALOG.md to find established agent implementation patterns.
    • Platform-Specific Guidance: The agent-docs/ directory contains references for specific tools like Claude Code, Codex CLI, and OpenCode.
  3. Features of agnix-lsp

    main

    The agnix-lsp server provides real-time validation and developer productivity features for agent configuration files:

    • Real-time Diagnostics: Validation occurs as you type (didChange), on file open, and on file save.
    • Comprehensive Rule Support: Supports all 456 agnix validation rules, including project-level cross-file rules (e.g., AGM-006, XP-004/005/006, VER-001).
    • Diagnostic Details: Maps severity levels (Error, Warning, Info) and displays specific rule codes in messages.
    • Code Actions: Provides quick-fix actions for auto-fixable diagnostics.
    • IntelliSense:
      • Hover: Documentation for frontmatter fields like name, version, and model.
      • Completions: Context-aware completions for frontmatter keys, values, and snippets.
  4. What agnix validates

    main

    agnix is a linter for agent configurations, supporting 443 rules across 40 categories. It validates a wide range of files used by various AI agent tools, including:

    • Skills: SKILL.md (34 rules)
    • Claude Code: settings.json (Hooks), CLAUDE.md/CLAUDE.local.md (Memory), .claude/output-styles/*.md (Output Styles), and .claude/settings.json (Settings)
    • Instructions & Agents: AGENTS.md (Cross-Tool), agents/*.md (Agents)
    • MCP: Tool definitions (26 rules)
    • GitHub Copilot: .github/copilot-instructions.md, .github/hooks/hooks.json, and related files
    • Cursor: .cursorrules, .cursor/rules/*.mdc, .cursor/hooks.json, and .cursor/environment.json
    • Cline: .clinerules, .clinerules/*.md, and .clinerules/*.txt
    • OpenCode: opencode.json and opencode.jsonc
    • Windsurf: .windsurf/rules/*.md, .windsurf/workflows/*.md, and .windsurfrules
    • Kiro: .kiro/steering/*.md, .kiro/agents/**/*.{json,md}, .kiro/hooks/*.kiro.hook, and .kiro/settings/*.json
    • Other tools: Gemini, Codex CLI, Roo Code, and Amp.
  5. Navigate the agnix Knowledge Base

    main

    The agnix Knowledge Base serves as the canonical documentation for validation rules, standards, and research sources used by the linter. Use the following files to find specific information:

    • INDEX.md: Use this for master navigation and high-level summaries of the knowledge base.
    • VALIDATION-RULES.md: Consult this file to view the 456 specific rules and their underlying detection logic.
    • PATTERNS-CATALOG.md: Reference this for the 70 patterns derived from agentsys.
    • standards/: Directory containing HARD-RULES and OPINIONS organized by topic.
    • agent-docs/: Directory containing platform references and research documentation.
  6. Understand Agnix Detection Certainty Levels

    main

    Agnix categorizes linting detections into three certainty levels, which determine how they are reported and whether they can be automatically fixed:

    • HIGH: >95% true positive rate. These are always reported and are considered safe for auto-fixing.
    • MEDIUM: 75-95% true positive rate. These are reported in the default mode; auto-fixing should be done with caution.
    • LOW: <75% true positive rate. These are only reported in verbose mode and are never auto-fixed.
  7. Sandbox and isolate code execution

    main

    AI-generated code poses risks like filesystem access, network exfiltration, and resource exhaustion. Use isolation technologies based on your required security level:

    • Docker: Low latency; provides process and namespace isolation. Best for development or trusted code.
    • gVisor: Medium latency; provides user-space kernel isolation. Best for semi-trusted code.
    • Firecracker microVM: Medium latency; provides full VM isolation. Best for untrusted code.
    • WebAssembly: Very low latency; provides memory-safe sandboxing. Best for lightweight isolation.

    Recommended Architecture: Use a Sandbox Controller to orchestrate and validate execution within an isolated environment that has no network by default, a read-only filesystem, and strict resource limits.

  8. Understand Agent Skill validation rules

    main

    Agnix validates Agent Skill files (typically YAML frontmatter followed by a body) to ensure they adhere to the agentskills.io specification. Key validation checks include:

    • AS-001: Ensures the file starts with --- (YAML frontmatter exists).
    • AS-002: Ensures the name field is present and not empty.
    • AS-004: Validates the name format. It should be a bare skill name or follow the <plugin>:<skill-name> pattern using kebab-case segments.

    If AS-001 fails, validation stops because the frontmatter cannot be parsed.

    // Example of how AS-001 and AS-002 are checked internally
    if !content.starts_with("---") {
        diagnostics.push(Diagnostic::error(path, 1, 0, "AS-001", "Missing YAML frontmatter".to_string()));
        return diagnostics;
    }
    
    if frontmatter.name.is_empty() {
        diagnostics.push(Diagnostic::error(path, 2, 0, "AS-002", "Missing required field: name".to_string()));
    }
  9. Understand platform-specific standards (Claude Code, MCP, Multi-Platform)

    main

    Agnix provides deep technical context for specific agentic platforms and protocols. Use these resources to understand the constraints and best practices for each:

    • Claude Code: Use standards/claude-code-HARD-RULES.md for technical specifications and standards/claude-code-OPINIONS.md for usage patterns.
    • MCP (Model Context Protocol): Use standards/mcp-HARD-RULES.md for protocol compliance and standards/mcp-OPINIONS.md for tool design patterns.
    • Multi-Platform: Use standards/multi-platform-HARD-RULES.md for the compatibility matrix and standards/multi-platform-OPINIONS.md for cross-platform tips.
    • Prompt Engineering: Use standards/prompt-engineering-HARD-RULES.md for research-backed requirements.
  10. Understand Codex CLI Sandbox Security

    main

    Codex CLI employs OS-level sandboxing to ensure safety, especially when running in full-auto mode.

    • macOS: Uses Apple's Seatbelt to wrap commands. By default, network access is blocked, and the process is confined to the working directory and temporary storage.
    • Linux: Uses Docker containerization. It includes an iptables firewall that denies all egress except for necessary API calls, providing full filesystem isolation.

    Full-Auto Mode Safety: In this mode, all commands are executed with network-disabled, confined to the working directory, and allowed access only to temporary storage.

  11. Negotiate MCP Capabilities

    main

    Both parties must respect the negotiated protocol version and only use capabilities successfully negotiated during initialization. If a server declares a capability, it MUST implement the associated methods.

    CategoryCapabilityRequired Implementation
    Servertoolstools/list, tools/call
    Serverresourcesresources/list, resources/read
    Serverpromptsprompts/list, prompts/get
    ServerloggingAccept log messages
    ClientrootsProvide filesystem roots
    ClientsamplingHandle LLM sampling requests
    ClientelicitationHandle user input requests
  12. Design Reference Skills for Background Knowledge

    main

    Reference Skills are used to provide background knowledge, conventions, or context that should be loaded automatically when relevant. They act as guardrails to reduce back-and-forth by providing the agent with established patterns (e.g., API design principles, folder structures, or coding standards).

    Pattern: Define a skill with a name and description that outlines the conventions to follow.

    ---
    name: api-conventions
    description: REST API design conventions for this codebase. Apply when working with API endpoints.
    ---
    
    ## API Design Principles
    
    ### URL Structure
    - Resources: Plural nouns (`/users`, not `/user`)
    - Nesting: Max 2 levels (`/users/:id/posts/:id`)
    - Actions: POST to collection, PUT to item
    
    ### Response Format
    ```json
    {
      "data": { /* response payload */ },
      "meta": {
        "page": 1,
        "total": 100
      }
    }

    Error Handling

    • 400: Client error (invalid input)
    • 401: Unauthorized
    • 403: Forbidden
    • 404: Not found
    • 500: Server error

    Validation

    • Use Zod schemas
    • Return detailed field errors
    • Include error codes for client handling