agentifind

This skill sets up codebase intelligence for AI agents by running the `agentifind` CLI to extract code structure and synthesize a `CODEBASE.md` navigation guide. It includes staleness detection and intelligently handles LSP installation for optimal accuracy.

68 stars
Complexity: medium

About this skill

The `agentifind` skill empowers AI agents to rapidly comprehend the structure and logic of any given codebase. It achieves this by invoking the `agentifind` CLI, which leverages Language Server Protocols (LSP) like `pyright` or `tsserver` and falls back to `tree-sitter` for robust code structure extraction. Beyond static analysis, it also aims to detect dynamic patterns that might be missed. A key output is a `CODEBASE.md` navigation guide, offering a clear, human-readable map of the project, along with a `codebase.json` for agent consumption. This skill is crucial for AI agents needing deep contextual understanding before performing coding tasks. By providing a comprehensive codebase map, it reduces the agent's need for extensive preliminary exploration, speeding up development, debugging, and feature implementation cycles. It ensures the agent has access to up-to-date architectural insights, complete with staleness detection to prompt regeneration when the code changes. It's particularly useful for onboarding new AI agents to unfamiliar repositories, aiding in complex refactoring operations, or generating initial project documentation. For repositories involving Infrastructure as Code (IaC) like Terraform, the skill intelligently checks for and installs `terraform-ls` to ensure highly accurate parsing and understanding, highlighting its adaptability and foresight in various coding environments.

Best use case

The primary use case is providing AI agents with an up-to-date, comprehensive understanding of a project's codebase before starting coding-related tasks. Developers and engineering teams benefit most by enabling their AI assistants to work more efficiently and accurately on large or complex repositories, reducing context-switching and improving the quality of AI-generated code or analysis.

This skill sets up codebase intelligence for AI agents by running the `agentifind` CLI to extract code structure and synthesize a `CODEBASE.md` navigation guide. It includes staleness detection and intelligently handles LSP installation for optimal accuracy.

A `CODEBASE.md` file will be generated or updated in the `.claude/` directory, providing a comprehensive and up-to-date navigation guide to the codebase, along with a `codebase.json` for agent consumption.

Practical example

Example input

Please set up codebase intelligence for this repository using the `agentifind` skill.

Example output

Codebase intelligence setup complete. A fresh `CODEBASE.md` and `codebase.json` have been generated in the `.claude/` directory, providing a comprehensive map of the project structure. Current commit hash: `[COMMIT_HASH]`.

When to use this skill

  • Before asking an AI agent to perform complex coding tasks in an unfamiliar codebase.
  • When you need an AI agent to generate documentation or architectural overviews of a project.
  • To ensure an AI agent has the most current understanding of a repository after significant changes.
  • When working with Terraform or other IaC projects where accurate code parsing is critical for the AI.

When not to use this skill

  • For very small, single-file scripts where codebase context is minimal or already explicit.
  • If you already have a perfectly up-to-date, AI-accessible `CODEBASE.md` and only minor, irrelevant changes have occurred.
  • When the agent's task does not require deep codebase understanding (e.g., simple text manipulation, external API calls).

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/agentifind/SKILL.md --create-dirs "https://raw.githubusercontent.com/AvivK5498/Beads-Kanban-UI/main/.claude/skills/agentifind/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/agentifind/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How agentifind Compares

Feature / AgentagentifindStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexitymediumN/A

Frequently Asked Questions

What does this skill do?

This skill sets up codebase intelligence for AI agents by running the `agentifind` CLI to extract code structure and synthesize a `CODEBASE.md` navigation guide. It includes staleness detection and intelligently handles LSP installation for optimal accuracy.

Which AI agents support this skill?

This skill is designed for Claude.

How difficult is it to install?

The installation complexity is rated as medium. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Agentifind: Codebase Intelligence Setup

This skill sets up codebase intelligence by:
1. Running agentifind CLI to extract code structure
2. Detecting dynamic patterns that static analysis can't fully trace
3. Synthesizing a navigation guide with staleness metadata

## Procedure

### Step 1: Check for existing guide (Staleness Detection)

If `.claude/CODEBASE.md` already exists, check if it's stale:

1. Read the metadata header from CODEBASE.md:
   ```
   Source-Hash: {sha256 of codebase.json when guide was generated}
   Commit: {git commit when generated}
   Stats: {file count, function count, class count}
   ```

2. Compare against current state:
   - Run `sha256sum .claude/codebase.json` (or equivalent)
   - Run `git rev-parse HEAD`
   - Read current stats from codebase.json

3. **If metadata matches**: Guide is fresh. Ask user if they want to regenerate anyway.
4. **If metadata differs or missing**: Guide is stale. Proceed with regeneration.
5. **If no CODEBASE.md exists**: Proceed with generation.

### Step 2: Detect repo type and install LSP (if needed)

Check if this is a Terraform/IaC repository:

```bash
# Check for .tf files
find . -name "*.tf" -type f | head -1
```

**If Terraform files are found:**

Check if `terraform-ls` is installed. If not, install it for better parsing accuracy:

```bash
# Check if terraform-ls exists
which terraform-ls || echo "NOT_INSTALLED"
```

**If NOT_INSTALLED, install terraform-ls:**

```bash
# macOS (Homebrew)
brew install hashicorp/tap/terraform-ls

# Or via Go (cross-platform)
go install github.com/hashicorp/terraform-ls@latest
```

**Why terraform-ls matters:**
- Proper HCL parsing (not regex)
- Accurate module resolution
- Cross-file reference tracking
- Provider schema awareness

If installation fails, agentifind will fall back to regex parsing (still functional but less accurate).

### Step 3: Run agentifind sync

Execute the CLI to extract code structure:

```bash
npx agentifind@latest sync
```

**Extraction Method:**
- **LSP first** (if available): Uses language servers for accurate cross-file resolution
  - Python: `pyright-langserver` (install: `npm i -g pyright`)
  - TypeScript: `tsserver` (bundled with TypeScript)
  - Terraform: `terraform-ls` (install: `brew install hashicorp/tap/terraform-ls`)
  - **Note: LSP extraction can take 5-15 minutes on large codebases** (building reference graph)
- **Regex/Tree-sitter fallback**: Fast parsing when LSP unavailable (~30 seconds)

This creates `.claude/codebase.json` with:
- Module imports/exports
- Function and class definitions
- Call graph relationships (more accurate with LSP)
- Import dependencies

**Options:**
- `--skip-validate`: Skip linting/type checks (faster)
- `--verbose`: Show extraction method and progress
- `--if-stale`: Only sync if source files changed

### Step 4: Update .gitignore

Add the generated files to `.gitignore` (if not already present):

```
# Agentifind generated files
.claude/codebase.json
.claude/CODEBASE.md
.claude/.agentifind-checksum
```

These files are:
- **Regeneratable** from source code
- **Large** (codebase.json can be several MB)
- **Machine-specific** (paths may differ)

### Step 5: Read and analyze extracted data

Read `.claude/codebase.json` and analyze:
- `stats`: File/function/class counts
- `modules`: Per-file structure (imports, exports, classes, functions)
- `call_graph`: What functions call what
- `import_graph`: Module dependencies
- `analysis_gaps`: Gaps in call graph (see Step 6)
- `validation`: Lint/type issues (if present)

### Step 6: Review analysis gaps

The CLI automatically detects gaps in the call graph that may indicate dynamic patterns. Read `analysis_gaps` from codebase.json:

```json
{
  "analysis_gaps": {
    "uncalled_exports": [...],  // Exported functions with no callers
    "unused_imports": [...],    // Imports never referenced
    "orphan_modules": [...]     // Files never imported
  }
}
```

**How to interpret gaps:**

| Gap Type | What It Means | Likely Cause |
|----------|---------------|--------------|
| `uncalled_exports` | Exported function has no detected callers | Entry point, CLI command, API handler, test fixture, plugin hook, signal receiver, decorator-invoked |
| `unused_imports` | Import never referenced in code | Side-effect import, re-export, type-only import, dynamically accessed |
| `orphan_modules` | File never imported by anything | Entry point, script, config file, dynamically loaded plugin |

**Key insight:** If something is exported but never called, or imported but never used, static analysis cannot trace it. These are the areas where the call graph is incomplete.

**No manual scanning required** - the CLI does this automatically by analyzing the call graph structure.

### Step 7: Identify key components

From the data, determine:
- **Entry points**: Files with many importers (check import_graph reverse)
- **Core modules**: High export count, central in import graph
- **Utilities**: Imported by many, import few themselves
- **Request flow**: Trace call_graph from entry to output

### Step 8: Write CODEBASE.md

**First, check `repo_type` in codebase.json:**
- If `repo_type` is `"terraform"` → Use the **Infrastructure Template** below
- If `repo_type` is missing or other → Use the **Application Template** below

---

#### Application Template (default)

Create `.claude/CODEBASE.md` with this structure:

```markdown
# Codebase Guide

<!-- STALENESS METADATA - DO NOT EDIT -->
<!--
Generated: {ISO 8601 timestamp}
Source-Hash: {sha256 of codebase.json}
Commit: {git commit hash}
Stats: {files} files, {functions} functions, {classes} classes
-->

## ⚠️ Usage Instructions

This guide provides STARTING POINTS, not absolute truth.

**Before acting on any location:**
1. Verify the file exists with a quick Read
2. Confirm the symbol/function is still there
3. If something seems wrong, the guide may be stale - regenerate with `/agentifind`

**This guide CANNOT see:**
- Runtime behavior (dynamic imports, plugins, DI)
- Configuration-driven logic
- Database queries and their relationships
- External API integrations

## Quick Reference

| Component | Location |
|-----------|----------|
| {name} | `{path}` → `{symbol}` |

## Architecture

### Module Dependencies
{Key relationships from import_graph - focus on core modules}

### Data Flow
{Trace from call_graph if clear pattern exists}

## Analysis Gaps (Potential Dynamic Patterns)

{If analysis_gaps has items, list them here grouped by type}

### Uncalled Exports
{List from analysis_gaps.uncalled_exports - these are likely entry points, API handlers, or dynamically invoked}

| Symbol | File | Reason |
|--------|------|--------|
| {name} | `{file}:{line}` | {reason} |

### Orphan Modules
{List from analysis_gaps.orphan_modules - these are likely entry points or dynamically loaded}

| File | Reason |
|------|--------|
| `{file}` | {reason} |

**What this means:**
- Call graph is incomplete for these symbols/files
- They may be invoked via plugins, signals, decorators, CLI, or configuration
- Always trace execution manually when working in these areas
- Don't assume the call graph shows all callers

{If no gaps found, write: "No analysis gaps detected. Call graph appears complete."}

## Conventions
{Infer from naming patterns, file organization, directory structure}

## Impact Map

| If you change... | Also update... |
|------------------|----------------|
| `{high-dependency file}` | {N} dependent files |

## Known Issues
{From validation.linting/formatting/types if present, otherwise omit section}
```

---

#### Infrastructure Template (for Terraform/IaC repos)

When `repo_type` is `"terraform"`, create `.claude/CODEBASE.md` with this structure:

```markdown
# Infrastructure Guide

<!-- STALENESS METADATA - DO NOT EDIT -->
<!--
Generated: {ISO 8601 timestamp}
Source-Hash: {sha256 of codebase.json}
Commit: {git commit hash}
Stats: {files} files, {resources} resources, {modules} modules
-->

## ⚠️ Usage Instructions

This guide provides STARTING POINTS for infrastructure navigation.

**Before making changes:**
1. Verify the resource/module exists
2. Check the blast radius (what depends on this?)
3. Review variable dependencies
4. Consider state implications

**This guide CANNOT see:**
- Remote state data
- Dynamic values from data sources
- Provider-specific behaviors
- Secrets in tfvars files

## Infrastructure Overview

| Provider | Resources | Modules |
|----------|-----------|---------|
{For each provider in stats.providers, count resources}

## Module Structure

{List from modules array, show source and dependencies}

```
modules/
├── {module.name}/  → {module.source}
│   └── inputs: {list key variables}
```

## Resource Inventory

{Group resources by type from resources object}

### {Provider} Resources
| Type | Name | File | Dependencies |
|------|------|------|--------------|
| {type} | {name} | `{file}:{line}` | {dependencies.length} deps |

## Variable Flow

{List from variables array}

| Variable | Type | Used By | Default |
|----------|------|---------|---------|
| {name} | {type} | {used_by.length} resources | {default or "required"} |

## Blast Radius (High Risk)

{List from blast_radius where severity is "high" or "medium"}

⚠️ **Changing these resources affects many dependents:**

| Resource | Affected | Severity |
|----------|----------|----------|
| {target} | {affected_resources.length} resources | {severity} |

**Before modifying high-risk resources:**
- Run `terraform plan` to preview changes
- Consider using `terraform state mv` for refactoring
- Check if changes will force recreation

## Outputs

{List from outputs array}

| Output | Value | Referenced |
|--------|-------|------------|
| {name} | {value} | {references} |

## Dependency Graph

{Describe key relationships from dependency_graph}

Key dependencies:
- `{resource A}` → depends on → `{resource B}`
```

### Step 9: Confirm completion

**For application repos**, report:
- Files analyzed (from stats.files)
- Symbols extracted (from stats.functions + stats.classes)
- Extraction method used (LSP or tree-sitter)
- Key entry points identified
- **Analysis gaps detected** (count of uncalled_exports, orphan_modules)
- Any validation issues found
- Guide staleness metadata recorded

**For Terraform/IaC repos**, report:
- Files analyzed (from stats.files)
- Resources extracted (from stats.resources)
- Modules detected (from stats.modules)
- Providers used (from stats.providers)
- **High-risk resources** (count from blast_radius with severity "high")
- Variables defined vs used
- Guide staleness metadata recorded

### Step 10: Offer to update agent instructions

Check if `CLAUDE.md` or `AGENTS.md` exists in the project root.

Ask the user:
> "Would you like me to add an instruction to your {CLAUDE.md/AGENTS.md} file so the agent automatically uses the CODEBASE.md for navigation?"

**If user accepts:**

Append this section to the file (or create `AGENTS.md` if neither exists):

```markdown
## Codebase Navigation

Before exploring the codebase, read `.claude/CODEBASE.md` for architecture overview, key files, and conventions. This file is auto-generated by agentifind and provides:
- Quick reference to key components
- Module dependencies and data flow
- Dynamic patterns that static analysis can't trace
- Coding conventions
- Impact map for changes

**Important:** The guide provides starting points. Always verify locations before making changes.
```

If both `CLAUDE.md` and `AGENTS.md` exist, update `CLAUDE.md` (takes precedence).

**If user declines:**

Respond with:
> "No problem! If you change your mind, add this to your CLAUDE.md or AGENTS.md file:"
>
> ```markdown
> ## Codebase Navigation
>
> Before exploring the codebase, read `.claude/CODEBASE.md` for architecture overview, key files, and conventions.
> ```

## Output

```
.claude/
├── codebase.json         # Structured extraction (CLI output)
├── CODEBASE.md           # Navigation guide (this skill's output)
└── .agentifind-checksum  # Staleness detection
```

## Notes

- Ground ALL claims in the extracted data - do not hallucinate relationships
- Keep the guide concise - focus on navigation over explanation
- Prioritize "what" and "where" over "why" and "how"
- If codebase.json already exists and is recent, skip Step 2
- LSP extraction is slower but more accurate for cross-file references
- Tree-sitter is faster but uses heuristic-based resolution
- **Always include the staleness metadata header** - it enables future freshness checks
- **Always include the analysis gaps section** - even if none found, document that the call graph is complete

Related Skills

laravel-expert

31392
from sickn33/antigravity-awesome-skills

Senior Laravel Engineer role for production-grade, maintainable, and idiomatic Laravel solutions. Focuses on clean architecture, security, performance, and modern standards (Laravel 10/11+).

Coding & DevelopmentClaude

webmcp

1093
from qdhenry/Claude-Command-Suite

This skill guides AI agents in implementing WebMCP within web projects, enabling browser-native structured tools for AI interaction using JavaScript or HTML APIs.

Coding & DevelopmentClaude

Prompt Coach

799
from bear2u/my-skills

Analyze your Claude Code session logs to improve prompt quality, optimize tool usage, and enhance your skills as an AI-native engineer.

Coding & DevelopmentClaude

nextjs

389
from udecode/better-convex

Provides comprehensive Next.js routing capabilities, including typed routes, helpers for `PageProps` and `LayoutProps`, and `nuqs` for managing URL state.

Coding & DevelopmentClaude

react

389
from udecode/better-convex

This AI agent skill guides the generation of modern React components, incorporating best practices such as destructured props, leveraging compiler optimizations, and proper use of React Effects. It also ensures compatibility and utilizes Tailwind CSS v4 syntax.

Coding & DevelopmentClaude

just

208
from disler/bowser

Use `just` to save and run project-specific commands. Use when the user mentions `justfile`, `recipe`, or needs a simple alternative to `make` for task automation.

Coding & DevelopmentClaude

chrome-debug

159
from majiayu000/claude-skill-registry

This skill empowers AI agents to debug web applications and inspect browser behavior using the Chrome DevTools Protocol (CDP), offering both collaborative (headful) and automated (headless) modes.

Coding & DevelopmentClaude

worktree-manager

125
from Wirasm/worktree-manager-skill

Create, manage, and cleanup git worktrees with Claude Code agents across all projects. USE THIS SKILL when user says "create worktree", "spin up worktrees", "new worktree for X", "worktree status", "cleanup worktrees", "sync worktrees", or wants parallel development branches. Also use when creating PRs from a worktree branch (to update registry with PR number). Handles worktree creation, dependency installation, validation, agent launching in Ghostty, and global registry management.

Coding & DevelopmentClaude

clearshot

124
from udayanwalvekar/clearshot

Structured screenshot analysis for UI implementation and critique. Analyzes every UI screenshot with a 5×5 spatial grid, full element inventory, and design system extraction — facts and taste together, every time. Escalates to full implementation blueprint when building. Trigger on any digital interface image file (png, jpg, gif, webp — websites, apps, dashboards, mockups, wireframes) or commands like 'analyse this screenshot,' 'rebuild this,' 'match this design,' 'clone this.' Skip for non-UI images (photos, memes, charts) unless the user explicitly wants to build a UI from them. Does NOT trigger on HTML source code, CSS, SVGs, or any code pasted as text.

Coding & DevelopmentClaude

osgrep

101
from pr-pm/prpm

Semantic code search using natural language queries. Use when users ask "where is X implemented", "how does Y work", "find the logic for Z", or need to locate code by concept rather than exact text. Returns file paths with line numbers and code snippets.

Coding & DevelopmentClaude

10up-css

87
from petenelson/wp-rest-api-log

CSS architecture, best practices, and patterns for WordPress projects. Covers ITCSS methodology, accessibility, specificity management, naming conventions, and modern CSS features.

Coding & DevelopmentClaude

CLAUDE.md – JJ Quick Command List

58
from mizchi/chezmoi-dotfiles

A concise cheat sheet for essential Jujutsu (`jj`) version control commands, designed to help AI agents or users quickly perform common repository operations.

Coding & DevelopmentClaude