Skip to the content.

at-ref - tooling for @path/to/file references

Tooling for Claude Code’s @path/to/file reference syntax

Parse, validate, and compile @path/to/file references in markdown. CLI tool and VS Code extension for validation, navigation, and compilation.

What is @reference syntax?

Claude Code uses @path/to/file syntax to reference files in markdown documentation. This project provides tools to:

<!-- Example usage -->
See @src/parser.ts for implementation details.
Configuration is in @config/settings.json.

Features

CLI Tool (at-ref)

Validation with Multiple Modes

Compilation with Optimization

Flexible Output Formats

VS Code Extension (at-ref)

Autocomplete

Context Menu Commands

Configuration Options

5 settings available in VS Code Settings (atReference.*):

Setting Type Default Description
enableDiagnostics boolean true Show error squiggles for invalid references
enableCompletion boolean true Enable autocomplete when typing @
enableHover boolean true Show file preview on hover
exclude array ["**/node_modules/**", "**/.git/**"] Patterns to exclude from autocomplete
previewLines number 10 Number of lines to show in hover preview

Installation

CLI Installation

npm install -g @u-b/at-ref

Or build from source:

git clone https://github.com/otrebu/at-ref.git
cd at-ref
pnpm install && pnpm build

# Link globally
cd packages/core
pnpm link --global

# Now use anywhere
at-ref CLAUDE.md

VS Code Extension Installation

Search for “at-ref” in the VS Code Extensions marketplace, or install manually:

cd packages/vscode
pnpm build
pnpm package  # Creates .vsix file

Then in VS Code: Extensions → ... → Install from VSIX

Usage

CLI Usage

Validation (Default Command)

# Recursive validation (default) - validates entire dependency tree
at-ref CLAUDE.md

# Fast shallow mode - only direct references
at-ref CLAUDE.md --shallow

# Output modes
at-ref docs/                     # Per-file breakdown
at-ref docs/ --summary           # Compact stats
at-ref docs/ --quiet             # Only files with errors
at-ref docs/ --verbose           # Show all references per file

# Ignore patterns (can use multiple times)
at-ref . --ignore "node_modules" --ignore "vendor"

Check Command

Scan workspace for broken references, grouped by target file:

# Check all markdown files in current directory
at-ref check

# Check specific directory
at-ref check docs/

# Verbose mode shows per-file breakdown
at-ref check --verbose

Compilation

Single File:

# Basic compilation (creates CLAUDE.built.md)
at-ref compile CLAUDE.md

# Custom output path
at-ref compile CLAUDE.md --output CLAUDE.compiled.md

# Optimization flags (frontmatter always stripped)
at-ref compile CLAUDE.md --optimize-duplicates

Folder Compilation:

# Compile entire directory (creates dist/ folder)
at-ref compile docs/

# With optimization (massive size reduction for interconnected files)
at-ref compile docs/ --optimize-duplicates

Examples

Knowledge Base Compilation

Compile interconnected notes into self-contained documents:

at-ref compile notes/ --optimize-duplicates

CI/CD Validation Pipeline

Fast validation for continuous integration:

# .github/workflows/validate-docs.yml
- name: Validate references
  run: at-ref . --shallow --quiet

Documentation Audit

Find all broken references across your project:

at-ref check --verbose

Architecture

Reference Syntax Rules

Core Library Flow

  1. parser.ts - Extract @references via regex
  2. resolver.ts - Convert paths to absolute
  3. validator.ts - Check file existence (recursive by default)
  4. compiler.ts - Expand references inline with circular detection
  5. heading-adjuster.ts - Adjust heading levels based on context
  6. dependency-graph.ts - Build and sort dependency graphs

API Reference

Use @u-b/at-ref programmatically:

import {
  extractReferences,
  validateFile,
  compileFile
} from '@u-b/at-ref';

// Parse references from text
const refs = extractReferences('See @src/index.ts for details');

// Validate file (recursive by default)
const result = validateFile('./CLAUDE.md');

// Compile file
const compiled = compileFile('input.md', {
  outputPath: 'output.md',
  optimizeDuplicates: true
});

Contributing

We welcome contributions! Guidelines:

License

MIT