# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Commands

```bash
# Install dependencies
npm install

# Build the extension
npm run compile

# Watch mode for continuous building during development
npm run watch

# Build for production (used before packaging)
npm run package

# Run tests
npm run test

# Lint code
npm run lint

# Check TypeScript types without building
npm run check-types

# Generate code snippets
npm run snippets

# Package extension for distribution
npm run build-patch
```

## Architecture Overview

This is a VS Code extension providing **language support** for **XanoScript**, a domain-specific language for backend API development. The extension focuses purely on language features: syntax highlighting, validation, completions, hover, diagnostics, and code snippets.

### Core Structure (`src/`)

- `src/extension.ts` - Main activation point, registers the language server
- `src/registerServer.ts` - Language server client setup (LSP over IPC)
- `src/snippets/` - XanoScript code snippet templates (.xs files) and build script
- `src/md.d.ts` - TypeScript declaration for `.md` file imports

### Language Server

The `language-server/` directory is a **Git submodule** with its own repository. It provides:

- Syntax highlighting (semantic tokens)
- Completion provider
- Hover information
- Go to definition
- Diagnostics/validation
- References and rename support
- Document symbols

Language server development should be done in its own repository.

### Language Configuration

- `language-configuration.json` - Bracket pairs, comments, auto-closing, surrounding pairs
- `syntaxes/xanoscript.tmLanguage.json` - TextMate grammar for syntax highlighting

### Build System

**esbuild Configuration** (`esbuild.js`):

- Builds extension client: `src/extension.ts` → `dist/extension.js`
- Builds language server: `language-server/server.js` → `dist/server.js`
- Builds language server worker: `language-server/language-server-worker.js` → `dist/worker.js`
- Production mode includes minification and tree shaking

### Snippets

Code snippets are defined as `.xs` files in `src/snippets/`. The `build.ts` script compiles them into `dist/xanoscript.json` during the build process. Comments (`//`) in snippet files become descriptions.

## Development Notes

- Language server development should be done in its own repository (submodule)
- Run lint and type checking before committing changes
