Root — AGENTS.md

Module: root-agents-md Cohesion: 0.80 Members: 0

Root — AGENTS.md

This document, AGENTS.md, serves as the foundational guide for developers contributing to the grok-cli project. Unlike a typical code module, it does not contain executable code but rather defines the project's development standards, workflow, and the prescribed usage of the GitNexus code intelligence platform.

Its primary purpose is to ensure consistency, maintainability, and safe development practices across the codebase by providing clear instructions on environment setup, coding style, testing, contribution workflow, and leveraging advanced code analysis tools.

Project Development Guidelines

This section outlines the essential practices and conventions for developing within the grok-cli repository. Adhering to these guidelines is crucial for maintaining code quality and project health.

Environment and Setup

  1. Run npm install to install dependencies.
  2. Copy .env.example to .env and configure the necessary environment variables.

Project Structure

The repository follows a standard structure to organize different types of files:

Build, Test, and Development Commands

A set of npm scripts are provided to streamline common development tasks:

Coding Style and Naming Conventions

Testing Guidelines

Contribution Workflow

  1. Branching: Create a new branch following conventional naming (e.g., feat/new-feature, fix/bug-fix, docs/update-readme).
  2. Implementation: Implement changes, ensuring focused tests are written.
  3. Validation: Run npm run validate to ensure all quality checks pass.
  4. Commit: Commit changes using Conventional Commits.
  5. Pull Request: Open a Pull Request, linking to relevant issues and providing evidence of validation.

Commit and Pull Request Guidelines

Security and Configuration

GitNexus Code Intelligence Guide

This section details the mandatory use of GitNexus, a code intelligence platform, for understanding, navigating, and safely modifying the grok-cli codebase. GitNexus provides advanced capabilities beyond traditional text search, leveraging a comprehensive graph of symbols and execution flows.

What is GitNexus?

GitNexus indexes the grok-cli project (referred to as grok-cli within GitNexus) to create a detailed map of its symbols, relationships, and execution flows. This allows developers to perform sophisticated queries, analyze impact, and refactor code with a higher degree of confidence.

Core Principles for Using GitNexus

Always Do:

Never Do:

Key Use Cases

When Debugging

  1. Identify Flows: gitnexus_query({query: ""}) to find execution flows related to the issue.
  2. Contextualize Suspects: gitnexus_context({name: ""}) to see all callers, callees, and process participation.
  3. Trace Execution: READ gitnexus://repo/grok-cli/process/{processName} to trace the full execution flow step by step.
  4. Regression Check: For regressions, gitnexus_detect_changes({scope: "compare", base_ref: "main"}) to identify changes introduced by your branch.

When Refactoring

  1. First, run gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true}) to preview changes.
  2. Review the preview (graph edits are safe, text_search edits require manual review).
  3. Then, run with dry_run: false to apply the rename.

  1. Run gitnexus_context({name: "target"}) to identify all incoming and outgoing references.
  2. Run gitnexus_impact({target: "target", direction: "upstream"}) to find all external callers before moving code.

GitNexus Tools Quick Reference

ToolWhen to useCommand Example
queryFind code by conceptgitnexus_query({query: "auth validation"})
context360-degree view of one symbolgitnexus_context({name: "validateUser"})
impactBlast radius before editinggitnexus_impact({target: "X", direction: "upstream"})
detect_changesPre-commit scope checkgitnexus_detect_changes({scope: "staged"})
renameSafe multi-file renamegitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})
cypherCustom graph queriesgitnexus_cypher({query: "MATCH ..."})

Impact Risk Levels

GitNexus impact analysis provides risk levels to guide your actions:

DepthMeaningAction
d=1WILL BREAK — direct callers/importersMUST update these
d=2LIKELY AFFECTED — indirect dependenciesShould test
d=3MAY NEED TESTING — transitive dependenciesTest if critical path

Resources

ResourceUse for
gitnexus://repo/grok-cli/contextCodebase overview, index freshness check
gitnexus://repo/grok-cli/clustersAll functional areas
gitnexus://repo/grok-cli/processesAll execution flows
gitnexus://repo/grok-cli/process/{name}Step-by-step execution trace

Self-Check Before Finishing

Before completing any code modification task, verify the following:

  1. gitnexus_impact was run for all modified symbols.
  2. No HIGH or CRITICAL risk warnings were ignored.
  3. gitnexus_detect_changes() confirms that changes match the expected scope.
  4. All d=1 (WILL BREAK) dependents were updated.

Keeping the GitNexus Index Fresh

The GitNexus index becomes stale after code changes. To update it:

npx gitnexus analyze

If the index previously included embeddings, preserve them by adding --embeddings:

npx gitnexus analyze --embeddings
**Note**: Running `analyze` without `--embeddings` will delete any previously generated embeddings. Check `.gitnexus/meta.json` for `stats.embeddings` to see if embeddings exist.

Relationship to the Codebase

AGENTS.md is a meta-document that defines the operational framework for developing the grok-cli codebase. It does not contain any executable code, nor does it participate in any direct call graphs or execution flows within the project. Instead, it dictates the processes, tools, and standards that govern the creation, modification, and maintenance of the actual source code. It is a critical resource for any developer looking to contribute effectively and safely to the grok-cli project.