Skip to content

Instantly share code, notes, and snippets.

@imaman
imaman / build-package-map.ts
Last active January 18, 2026 10:06
opus fails to detect DRY violation
import * as fs from 'node:fs'
import * as path from 'node:path'
import type { DependencyGraph, MonorepoPackage, PackageLocation, PackageMap } from './types.js'
function getDistDir(main: string | undefined): string {
const mainPath = main ?? 'dist/index.js'
const dir = path.dirname(mainPath)
return dir || 'dist'
}
@imaman
imaman / brainstorm.md
Created January 18, 2026 08:07
brainstorming claude code (sub)agent
name description tools model color
brainstorm
when a problem need to be identified/discussed/solution-need-to-be-shaped
Glob, Grep, Read, WebFetch, TodoWrite, WebSearch, Bash
opus
yellow

you are a principal engineer (world class understanding of coding, crafts, typescript, open source ecosystem) and we are in an office hour where you consult other projects.

@imaman
imaman / CLAUDE.md
Last active January 15, 2026 06:54
our CLAUDE.md file
@imaman
imaman / percentile.js
Created January 1, 2026 12:44
distribution (yearly casualties in car accidents)
const input = [
[2005, 465],
[2006, 439],
[2007, 415],
[2008, 433],
[2009, 346],
[2010, 375],
[2011, 382],
[2012, 290],
[2013, 309],
@imaman
imaman / ZOD_V4_MIGRATION_GUIDE.md
Last active January 4, 2026 20:00
Zod v4 Migration Guide: Breaking Changes, UUID Validation, String Format Methods, Record Schema Updates, and Error Message Changes

Zod v4 Migration Guide

I made Claude Code suffer through migrating a production monorepo with 131 packages to Zod v4, then made it document everything.

Consider this your cheat sheet—all the breaking changes, gotchas, and fixes you need, battle-tested on mission-critical code.

1. Package Updates

// Before
@imaman
imaman / search-claude-code-logs.js
Last active November 17, 2025 11:04
lists the subagents that were actually used by claude code
const fs = require('fs')
const path = require('path')
const os = require('os')
const d = path.join(os.homedir(), PICK_YOUR_CLAUDE_CODE_DIRECTORY)
const objects = fs.readdirSync(d).map(at => path.join(d, at)).filter(at => at.endsWith('.jsonl')).flatMap(at => {
return fs.readFileSync(at, 'utf-8').split('\n').flatMap((line, i) => {
if (!line.trim()) {
return []
@imaman
imaman / simple-prompt.sh
Created May 29, 2021 10:35
simple bash prompt
BLUE="\[\033[01;34m\]"
~/code/sample-monorepo$ WHITE="\[\033[01;00m\]"
~/code/sample-monorepo$ PS1="${debian_chroot:+($debian_chroot)}$BLUE\w\$ $WHITE"
@imaman
imaman / my-public-key
Created September 20, 2020 05:31
my public key
require('crypto').publicEncrypt("-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxm6YetHJ5gdhv7TmD9uD\nl4XErogLhypON/Hi0Qvsy3QVXukbziVKBB4pgtNU303NMTVYuakUpYuyVuOiwaTv\nXVf8gyB6MzhbaUpVkPQimbt24kAXVmIUAA/7Hg6QqfssBFfwB+vBmPPzoZflHz1M\n+sx6pdyKwM1hK41evnTzjfY11Xhc3RmmLtPxWOSF2oR+hZ2lCtDgc5CKWQ5f5ade\n4s3RNiIKaV8U0oR4SKf1ty0PSW7/C+RPO2b7NlHKurLDIsCmTjxOkyYboQlJhH3W\nevjHrDF9Oli2mRsHPMidjkTgdjdugwda38rNS6ZvFbhNWd55HtRNCxjblFhIbs0X\nln/I86fbhOPNBt3VKBhE2lV6cgFg76JI7vS12uiQmtdj1RixulrgH8xrD+gpyyoi\nORgAYtflgr1DRHFerBqGCzds/bbR6FG/Luy3yK2zzBDVPRbM4hks3/sAZf3LVtED\nWDRB9E+Vb8SRWytidkp33l5d+2V03EE4+WalpG9FRVJCFQYSXd/ebT1qVfZMECZB\nsNrZxuznBOl8cPYA2Tros/k9hE10xCDMZbWi0Q4IKqgmCW7z9HR+D22HPwyXRsVH\nK1jyT8/1r7Qg6eEHDaGWYP5QbdrXxFUx6kFSBsglKajjaQO06VGb4XnBBArDG9Hp\nV8g3LLykdaFU592oN57DkfcCAwEAAQ==\n-----END PUBLIC KEY-----\n", Buffer.from('plain-text')).toString('hex')
@imaman
imaman / crypto-example.js
Created September 20, 2020 05:19
node crypto public/private keys
var keys = {}
crypto.generateKeyPair('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
@imaman
imaman / resolves vs. await
Created August 13, 2020 10:55
why I don't like .resolves
// with .resolves
expect(received).resolves.toBeDefined()
Received promise rejected instead of resolved
Rejected to value: [RequestError: Invalid authorization token provided: Bearer 0a933cd4bceffa68993ca34d58f31684d0923d31]
50 | })
51 |
> 52 | await expect(driver.runPr()).resolves.toBeDefined()