Claude Code Angular LSP Integration
Claude Code can leverage Angular Language Service output for template type checking, component navigation, and accurate refactoring. This guide shows you how to configure your Angular project so Claude Code gets LSP-quality feedback when generating and modifying Angular code.
The Problem
Claude Code generates Angular templates that look syntactically correct but fail strict template type checking. It references properties that do not exist on components, uses wrong pipe names, or binds to outputs with incorrect event types. Without LSP feedback, Claude Code cannot catch these errors before you run ng build and discover a wall of template diagnostics.
Quick Solution
Step 1: Enable strict template checking
In your tsconfig.json, ensure strict Angular compiler options are set:
{
"compilerOptions": {
"strict": true
},
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
Step 2: Add a type-check command to CLAUDE.md
## Verification
- After modifying any component or template, run: `npx ng build --configuration=development 2>&1 | head -50`
- Fix ALL template type errors before moving on
Step 3: Configure a pre-edit hook for Angular files
Create .claude/hooks.json:
{
"hooks": {
"postEdit": [
{
"command": "npx ng build --configuration=development --no-progress 2>&1 | tail -20",
"pattern": "**/*.component.ts,**/*.component.html"
}
]
}
}
This runs the Angular compiler after Claude Code edits any component file, surfacing template errors immediately.
Step 4: Give Claude Code your component inventory
find src/app -name "*.component.ts" | head -50 > .claude/component-list.txt
Reference this file in CLAUDE.md so Claude Code knows what components exist without scanning the entire tree.
How It Works
Angular Language Service provides type checking for templates by analyzing component classes, their inputs/outputs, and the TypeScript types flowing through bindings. When strictTemplates is enabled, the Angular compiler catches errors like binding to a nonexistent @Input(), using a pipe that does not exist in the module scope, or passing the wrong type to an event binding.
Claude Code does not run the Angular Language Service directly – it is a CLI tool, not an IDE. However, by configuring hooks that run ng build after edits, Claude Code gets the same diagnostic feedback that VS Code’s Angular Language Service provides. The Angular compiler outputs error messages with file paths and line numbers, which Claude Code can parse and use to self-correct.
The CLAUDE.md file closes the gap by documenting your component structure, shared modules, and naming conventions. This gives Claude Code the context to generate correct code on the first attempt, reducing the number of build-fix cycles.
Common Issues
“Template type checking is not enabled” warnings
You are missing strictTemplates: true in angularCompilerOptions. This is separate from TypeScript’s strict mode. Both must be enabled for full template type checking.
Hook runs but Claude Code ignores errors
Ensure the hook command outputs to stdout (not just stderr). Use 2>&1 redirection so Angular compiler errors are captured. Claude Code reads hook output to decide if the edit succeeded.
Slow compilation on every edit
The full ng build can be slow on large projects. Use ng build --configuration=development to skip production optimizations. For even faster feedback, use npx tsc --noEmit as a pre-check – it catches TypeScript errors (though not template-specific ones).
Example CLAUDE.md Section
# Angular LSP-Aware Development
## Compiler Settings
- strictTemplates: enabled (tsconfig.json)
- strictInjectionParameters: enabled
- Target: ES2022, Angular 17
## Verification After Every Change
- Run `npx ng build --configuration=development` after editing components
- Zero tolerance for template type errors
- Check test: `npx ng test --watch=false --browsers=ChromeHeadless`
## Component Patterns
- All components use OnPush change detection
- Inputs: use readonly + required where applicable
- Outputs: EventEmitter<T> with typed payloads
- Templates: no 'any' types — every binding is fully typed
## Shared Module Exports
- SharedModule exports: CommonModule, ReactiveFormsModule, MaterialModule
- Import SharedModule in every feature module
- Do NOT import BrowserModule in feature modules
## File Conventions
- Component class: PascalCase (ProductListComponent)
- Selector: kebab-case with 'app-' prefix (app-product-list)
- One component per file, co-located .html and .scss
Best Practices
-
Always enable strictTemplates – This is the single most impactful setting for Claude Code’s Angular accuracy. It turns template type errors from runtime surprises into compile-time catches.
-
Use hooks for automatic verification – Configure a postEdit hook that runs the Angular compiler. Claude Code will automatically detect and fix errors without you asking.
-
Document your shared modules – Claude Code cannot easily discover what is exported from SharedModule. List key exports in CLAUDE.md so it imports from the right module.
-
Keep component list updated – Periodically regenerate your component inventory file so Claude Code knows about new components added by other team members.
-
Prefer
ng buildoverng servefor verification –ng serveruns a dev server that is harder to use in hooks.ng buildwith development configuration gives the same diagnostics without starting a server.
Related Reading
- Best Way to Use Claude Code for Debugging Sessions
- Best Way to Integrate Claude Code into Team Workflow
- Claude Code MCP Server Setup
Built by theluckystrike. More at zovo.one