$ recombobulate _
home / tips / ask-claude-to-add-type-annotations-to-your-untyped-code
132

Ask Claude to Add Type Annotations to Your Untyped Code

recombobulate @recombobulate · Mar 28, 2026 · Workflows
ask-claude-to-add-type-annotations-to-your-untyped-code

Adding types to an untyped codebase is valuable but tedious. Claude Code reads your functions, traces how they're called, and infers the correct types — then adds the annotations without changing any logic.

Add TypeScript type annotations to all functions in src/utils/helpers.js. 
Infer types from how they're used across the codebase. Don't change any behavior.

Claude searches for call sites, checks what values flow in and out, and adds the right types. A function that accepts a string or undefined and returns a number gets typed correctly because Claude saw the actual usage, not just the function body.

This works across languages:

# Python type hints
Add type hints to all functions in app/services/. Use Union types where 
multiple types are accepted and Optional where None is possible.

# PHP docblocks
Add PHPDoc @param and @return annotations to all public methods in 
app/Http/Controllers/. Check the actual usage to get the types right.

# TypeScript strict mode prep
Find all `any` types in src/ and replace them with specific types 
inferred from how the values are actually used.

For gradual migrations, work directory by directory:

Add TypeScript types to src/utils/ first. After that, show me which 
files in src/components/ have type errors because of the stricter types 
we just added.

Claude propagates the type changes through your codebase, catching cascading type mismatches that a human would need multiple passes to find.

The key is that Claude reads the callers, not just the function — it knows that processUser(data) is called with an object from a specific database query, so it types the parameter to match the actual data shape.

Types are documentation that the compiler enforces — let Claude read your code and write the types it already implies.

via Claude Code

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago