npm package: @juanpprieto/claude-lsp
Description: Multi-service daemon providing TypeScript, ESLint, Prettier, and GraphQL analysis for Claude Code with automatic hooks
Author: Call The Guys
Latest version: 1.0.5

# Claude Code Intelligence

Real-time code analysis for Claude Code. Runs TypeScript LSP, ESLint, Prettier, and GraphQL checks automatically as Claude reads and writes files.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js](https://img.shields.io/badge/Node.js-18+-green)](https://nodejs.org)

## What This Does

When you ask Claude to read or edit a file, this plugin analyzes it immediately and feeds the results back to Claude. Claude sees type errors, linting issues, and formatting problems alongside the code—so it can fix them correctly the first time.

The system runs as a background daemon that starts when you open Claude Code and stops when you close it. Everything is automatic.

## Why Use This

Without this plugin, Claude sees your code but doesn't know what's broken. It might introduce type errors, violate your linting rules, or format code inconsistently with your project standards.

With this plugin, Claude gets the same information your IDE shows:

- Type errors from TypeScript
- Linting violations from ESLint
- Formatting issues from Prettier
- GraphQL schema validation errors

Claude can then provide fixes that actually work with your codebase.

## How It Works

<details>
<summary>Technical Flow (click to expand)</summary>

```
1. Claude Code starts → SessionStart hook fires
2. Hook starts daemon → Daemon detects project configs → Enables relevant services
3. You ask Claude to read src/app.ts
4. PostToolUse hook intercepts → Sends file to daemon → Gets analysis results
5. Hook injects diagnostics into Claude's context
6. Claude sees: file content + 2 type errors + 3 lint warnings + formatting issues
7. Claude provides precise fixes based on actual project requirements
8. You close Claude → SessionEnd hook stops daemon gracefully
```

The daemon exposes an MCP (Model Context Protocol) server that Claude can query directly for on-demand analysis.

</details>

---

## Installation

Requires Node.js 18+ and npm 9+.

```bash
# Install globally (one time only)
npm install -g @juanpprieto/claude-lsp

# Navigate to your project
cd your-project

# Initialize in your project (configures hooks and MCP server)
claude-intelligence-init

# Start Claude Code (daemon starts automatically)
claude
```

**That's it!** The package only needs to be installed globally. The init command configures hooks that use `npx` to find the global installation automatically. The daemon detects your project config files and enables the right services.

**To remove from a project:**

```bash
# Removes all hooks, configs, and daemon files
claude-intelligence-uninit

# Or use npx
npx claude-intelligence-uninit

# Optional: Uninstall the package entirely
npm uninstall -g @juanpprieto/claude-lsp
```

<details>
<summary>Development Installation</summary>

```bash
git clone https://github.com/juanpprieto/claude-lsp
cd claude-lsp
npm install
npm run build
npm link
```

</details>

## What Happens Automatically

The init command updates `.claude/settings.local.json` with:

1. **SessionStart Hook** - Starts daemon when Claude opens
2. **PostToolUse Hook** - Analyzes files after Read/Write/Edit operations
3. **SessionEnd Hook** - Stops daemon when Claude closes
4. **MCP Server** - Registers `code-intelligence` server for on-demand queries

Claude can now call `analyze_file`, `check_typescript`, `check_eslint`, `check_prettier`, or `check_graphql` whenever it needs analysis results

---

## Service Detection

The daemon scans your project and enables services based on what config files it finds:

| Service    | Looks For                                                      |
| ---------- | -------------------------------------------------------------- |
| TypeScript | `tsconfig.json`, `jsconfig.json`                               |
| ESLint     | `.eslintrc.*`, `eslint.config.js`, `package.json:eslintConfig` |
| Prettier   | `.prettierrc.*`, `prettier.config.js`, `package.json:prettier` |
| GraphQL    | `.graphqlrc*`, `graphql.config.*`, `graphql` in dependencies   |

No config files found? No services run. The daemon only activates what you actually use.

<details>
<summary>Manual Override (rarely needed)</summary>

Create `~/.claude/code-intelligence.json`:

```json
{
  "services": {
    "typescript": { "enabled": true },
    "eslint": { "enabled": false },
    "prettier": { "enabled": "auto" }
  }
}
```

</details>

---

## MCP Tools

Claude can call these tools directly through the MCP server:

| Tool               | Purpose                            | Returns                                                         |
| ------------------ | ---------------------------------- | --------------------------------------------------------------- |
| `analyze_file`     | Run all enabled services on a file | Combined diagnostics from TypeScript, ESLint, Prettier, GraphQL |
| `check_typescript` | Get TypeScript errors and warnings | Type errors, unused variables, signature problems               |
| `check_eslint`     | Get linting violations             | Code quality issues, style violations, best practice warnings   |
| `check_prettier`   | Check formatting                   | Formatting inconsistencies and required fixes                   |
| `check_graphql`    | Validate GraphQL files             | Schema validation errors, query problems                        |

The MCP server runs on stdio and validates daemon health before executing any tool. If the daemon isn't running, it returns an error immediately.

---

## Hook Integration

The plugin installs three Claude Code hooks:

**SessionStart Hook** - Starts daemon when Claude opens, detects configs, reports enabled services

**PostToolUse Hook** - Analyzes files after Read/Write/Edit operations, injects diagnostics as additional context

**SessionEnd Hook** - Stops daemon when Claude closes, cleans up resources

---

## Configuration

<details>
<summary>Global Configuration (optional)</summary>

Create `~/.claude/code-intelligence.json` to override defaults:

```json
{
  "services": {
    "typescript": { "enabled": "auto" },
    "eslint": {
      "enabled": "auto",
      "severity": ["error", "warning"],
      "excludeRules": ["no-console"]
    },
    "prettier": { "enabled": "auto", "checkOnly": true }
  },
  "server": { "port": 3141, "host": "localhost" },
  "logging": { "level": "info", "file": "~/.claude/code-intelligence.log" }
}
```

</details>

<details>
<summary>Project Configuration (optional)</summary>

Create `.claude/code-intelligence.json` to override global config:

```json
{
  "services": {
    "typescript": { "enabled": true },
    "eslint": { "enabled": false }
  }
}
```

</details>

## Troubleshooting

**Daemon won't start**

```bash
tail -f ~/.claude/code-intelligence.log
```

**Services not detected**

```bash
# Verify config files exist
ls tsconfig.json .eslintrc.* .prettierrc.*
```

**Hooks not executing**

```bash
# Verify hooks installed
cat .claude/settings.local.json
```

---

## Development

```bash
git clone https://github.com/juanpprieto/claude-lsp
cd claude-lsp
npm install
npm run build
npm link
```

**Quality checks:**

```bash
npm run validate  # typecheck + lint + format:check + test
npm test          # Run test suite
```

**Pre-commit hooks enforce:**

- TypeScript strict mode
- ESLint zero warnings
- Prettier formatting
- All tests passing

---

## Roadmap

**v1.0** - TypeScript, ESLint, Prettier, GraphQL support with MCP + hooks

## License

MIT - see [LICENSE](LICENSE)