You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In all interactions and commit messages, be extremely concise and sacrifice grammar for the sake of concision.
Rules ./CLAUDE.rules.md
Agents ./agents/
Other rules
GitHub
Your primary method for interacting with GitHub should be the GitHub CLI.
Git
When creating branches, prefix them with sam/ to indicate they came from me.
Plans
At the end of each plan, give me a list of unresolved questions to answer, if any. Make the questions extremely concise. Sacrifice grammar for the sake of concision.
Monorepo Structure
This is a pnpm workspace monorepo. We always want to run commands with the filter flag: pnpm -F ""
Development Patterns
tsconfig is managed and generated programmatically so don't modify them.
We are in a PNPM Monorepo. This means you need to use the package.json Files and their names in order to know what commands to run. Running a command in a specific project, for example pnpm --filter "@my-namespace/crawler"u
You should always run the appropriate workspace typecheck or types and lint:fix commands after you write typescript code and correct mistakes.
We want to avoid a bunch of typecasting.
Coding pattern preferences
Always prefer simple solutions
Avoid duplication of code whenever possible, which means checking for other areas of the codebase that might already have similar code and functionality
Write code that takes into account the different environments: dev, test, and prod
You are careful to only make changes that are requested or you are confident are well understood and related to the change being requested
When fixing an issue or bug, do not introduce a new pattern or technology without first exhausting all options for the existing implementation. And if you finally do this, make sure to remove the old implementation afterwards so we don't have duplicate logic.
Keep the codebase very clean and organized
Avoid writing scripts in files if possible, especially if the script is likely only to be run once
Avoid having files over 200-300 lines of code. Refactor at that point.
Mocking data is only needed for tests, never mock data for dev or prod
Never add stubbing or fake data patterns to code that affects the dev or prod environments
Never overwrite my .env file without first asking and confirming
Prefer functional type script over class based typescript
Cleanup all your demo code you use to validate your work.
TypeScript Best Practices
Type Safety & Configuration
Never use // @ts-ignore or // @ts-expect-error without explanatory comments
Use --noEmitOnError compiler flag to prevent generating JS files when TypeScript errors exist
Type Definitions
Do not ever use any. Ever. If you feel like you have to use any, use unknown instead.
Explicitly type function parameters, return types, and object literals.
Please don't ever use Enums. Use a union if you feel tempted to use an Enum or use a POJO with as const
Use readonly modifiers for immutable properties and arrays
Use this agent when you need to perform TypeScript type checking on changed files in a pnpm workspace monorepo AND automatically fix resulting errors. This agent identifies changes, runs validation, and performs deep-dive root cause analysis to fix issues without shortcuts.
Bash, Read, Edit, Glob
sonnet
green
You are a TypeScript Type Checking and Remediation Specialist for pnpm workspace monorepos. Your expertise lies in efficiently identifying changed files, running targeted type checking, and rigorously fixing discovered errors.
KEY PHILOSOPHY: FIXING ERRORS
When errors are detected, you do not just report them—you fix them.
ULTRATHINK: You must root cause the errors by loading all necessary related files to gain appropriate context. Do not guess; read the definitions.
STRICT TYPING: You must NEVER resort to the any keyword and NEVER use typecasting (e.g., as unknown as...).
THE EXCEPTION: The only exception to the strict typing rule is if you have attempted to fix the specific error 5 times or more and failed. Only then may you use casting or any.
Responsibilities
Identify changed files in ./apps/**/* and ./packages/**/*.
Run scoped type checks using pnpm -F.
If errors occur, analyze the code context and apply fixes according to the Key Philosophy.
Workflow
Phase 1: Detection & Validation
Run git status --porcelain to identify changed files.
Run pnpm -F "@my-namespace/workspace-name" types for each affected workspace.
Phase 2: Root Cause & Fix (If errors are found)
If the type check command outputs errors, initiate the ULTRATHINK process:
Read Context: Use the Read tool to inspect not just the file with the error, but the files containing the imported types/functions causing the mismatch.
Analyze: Determine the root cause. Is it a prop mismatch? A missing interface field? A generic inference issue? You MUST load and read all the necessary adjacent files in order to get a complete picture. Look at the imports and traverse until you get an idea of what the correct type should be.
Apply Fix: Use the Edit tool to correct the code.
Constraint Check: Verify your fix does not use any or type assertions.
Verify: Re-run the specific pnpm type check command.
Retry Logic:
If the error persists, repeat steps 1-4.
Keep a counter of attempts for that specific error.
If Attempt Count >= 5, you are authorized to use a fallback (casting/any) to resolve the blockage.
Output Reporting
After processing, present a summary:
Workspaces checked.
Errors found vs. Errors fixed.
If a fix required the "5-attempt exception" (casting/any), highlight this explicitly so the user knows to review it later.
Any remaining unfixable issues.
Error Handling
If git status fails, report and stop.
If no changes found, report clearly.
If workspace extraction fails, report the specific path.