angular-interceptors
ALWAYS use when working with Angular HTTP Interceptors, request/response transformation, auth interceptors, or error handling in HTTP calls.
Works with
Agent Skills format with YAML frontmatter. Claude Code reads it as-is.
---
name: "angular-interceptors"
description: "ALWAYS use when working with Angular HTTP Interceptors, request/response transformation, auth interceptors, or error handling in HTTP calls."
license: "MIT"
---
# Angular HTTP Interceptors
**Version:** Angular 21 (2025)
**Tags:** HTTP, Interceptors, Auth, Middleware
**References:** [Interceptors Guide](https://angular.dev/guide/http/interceptors) • [API](https://angular.io/api/common/http/HttpInterceptor)
## API Changes
This section documents recent version-specific API changes.
- NEW: Functional interceptors — Use `HttpInterceptorFn` instead of class-based
- NEW: provideHttpClient with withInterceptors — Modern interceptor setup
- NEW: HttpContext — Per-request metadata with HttpContextToken
- DEPRECATED: Class-based HttpInterceptor — Migrate to functional
## Best Practices
- Create functional interceptor
```ts
export const authInterceptor: HttpInterceptorFn = (req, next) => {
const authService = inject(AuthService);
const token = authService.getToken();
if (token) {
const authReq = req.clone({
setHeaders: { Authorization: `Bearer ${token}` }
});
return next(authReq);
}
return next(req);
};
```
- Register interceptors
```ts
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(
withInterceptors([authInterceptor, logInterceptor])
)
]
};
```
- Handle errors in interceptor
```ts
export const errorInterceptor: HttpInterceptorFn = (req, next) => {
return next(req).pipe(
catchError((error: HttpErrorResponse) => {
if (error.status === 401) {
inject(Router).navigate(['/login']);
}
return throwError(() => error);
})
);
};
```
- Use multiple interceptors (order matters)
```ts
provideHttpClient(
withInterceptors([loggingInterceptor, authInterceptor, errorInterceptor])
)
```
- Use HttpContext for per-request flags
```ts
const CACHE_KEY = new HttpContextToken<boolean>(() => false);
export const cacheInterceptor: HttpInterceptorFn = (req, next) => {
if (req.context.get(CACHE_KEY)) {
// Check cache
}
return next(req);
};
// Usage
http.get('/api/data', { context: new HttpContext().set(CACHE_KEY, true) });
```
- Transform request
```ts
export const transformInterceptor: HttpInterceptorFn = (req, next) => {
if (req.url.includes('/api/')) {
const transformed = req.clone({
setHeaders: { 'X-Custom-Header': 'value' }
});
return next(transformed);
}
return next(req);
};
```
- Transform response
```ts
export const responseInterceptor: HttpInterceptorFn = (req, next) => {
return next(req).pipe(
map(event => {
if (event instanceof HttpResponse) {
return event.clone({ body: transformData(event.body) });
}
return event;
})
);
};
```More Frontend Frameworks skills
frontend-design
anthropics/skills
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.
design-taste-frontend
leonxlnx/taste-skill
Anti-slop frontend skill for landing pages, portfolios, and redesigns. The agent reads the brief, infers the right design direction, and ships interfaces that do not look templated. Real design systems when applicable, audit-first on redesigns, strict pre-flight check.
hyperframes-creative
heygen-com/hyperframes
Non-animation creative direction for HyperFrames videos. Use for design spec (frame.md / design.md) handling, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns, and brand / style decisions. For atomic motion patterns and scene blueprints, use hyperframes-animation.

