Detects unnecessary heap allocations on hot paths in C#/.NET, TypeScript/JavaScript, Python, Java/Kotlin, and Go. Runs a stack-specific checklist and rewrites code to reduce GC pressure.
Ships in AI for Developers Toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Spot avoidable heap allocations on hot paths and rewrite them to cut GC pressure - without sacrificing readability where it doesn't matter.
Works on a target: a file, folder, project, or GitHub URL (clone first: git clone --depth 1 <url> /tmp/repo). Focus on hot paths: request handlers, tight loops, serialization, parsing, per-message processing. If the user has a profile or allocation report, start from its top frames; otherwise ask which paths are hot or confirm with hotpath-profiler-assistant.
| Manifest | Stack | Measure allocations with |
|---|---|---|
*.csproj | C# / .NET | BenchmarkDotNet [MemoryDiagnoser], dotnet-counters allocation rate, dotnet-trace |
package.json | TS / JS (V8) | --heap-prof, DevTools allocation sampling, process.memoryUsage() deltas |
pyproject.toml, requirements*.txt | Python | tracemalloc, memray, scalene |
pom.xml, build.gradle(.kts) | Java / Kotlin | JMH with -prof gc, JFR allocation events, async-profiler alloc mode |
go.mod | Go | go test -bench . -benchmem, pprof -sample_index=alloc_space, go build -gcflags=-m |
Find candidates, e.g.:
# .NET
grep -rn "\.Select(\|\.Where(\|\.ToList()\|+ \"\|string.Format\|new \[\]" --include=*.cs <target> | grep -v "/obj/\|/bin/"
# TS / JS
grep -rnE "\.(map|filter|reduce)\(.*\)\.(map|filter)|\.\.\.|JSON\.parse\(JSON\.stringify" --include=*.{ts,js} <target> | grep -v node_modules
# Python
grep -rnE "\+= ['\"]|\[.* for .* in .*\]|copy\.deepcopy|\.copy\(\)" --include=*.py <target>
# Java / Kotlin
grep -rnE "\.stream\(\)|String\.format|Pattern\.compile|\.split\(|new ObjectMapper" <target>/src
# Go
go build -gcflags=-m ./... 2>&1 | grep "escapes to heap"
grep -rn "fmt\.Sprintf\|\[\]byte(\|string(" --include=*.go <target>
Integer, any). Keep primitives primitive.new of something that could be static or pooled.Where/Select/ToList allocate iterators + lists per call; a plain for/foreach with no intermediate collection avoids it.object/interface (non-generic APIs, struct enumerators via interface). Use generics; avoid object.static lambdas.StringBuilder, string.Create, or interpolated string handlers.params arrays - hidden array per call; provide non-params overloads (or params ReadOnlySpan<T> on C# 13+).Task allocation - a method that usually completes synchronously -> ValueTask (await once only).in/ref readonly, readonly struct.List/Dictionary capacity.Substring/ToArray -> ReadOnlySpan<char>/AsSpan()/Memory<T>; rent big buffers from ArrayPool<T>.Shared.// allocates: closure + iterator + list, every call
var ids = items.Where(i => i.IsActive).Select(i => i.Id).ToList();
// hot path: no intermediate allocations
var ids = new List<int>(items.Count);
foreach (var i in items) if (i.IsActive) ids.Add(i.Id);
filter().map().reduce() chains on large arrays in hot paths - each step allocates a new array; fuse into one for loop.acc = { ...acc, [k]: v } or [...arr, x] inside a loop is O(n^2) allocation; mutate a local object/array, then return it.JSON.parse(JSON.stringify(x)) - allocates a full string and graph; avoid cloning, or use structuredClone when a clone is genuinely needed.new RegExp in loops with dynamic patterns - build once.Buffer.concat in a loop; collect chunks and concat once, or stream.[f(x) for x in xs] passed straight to sum/any/max -> generator expression.s += part -> "".join(parts); bytes -> bytearray or io.BytesIO.__slots__ (or @dataclass(slots=True)), or tuples/NamedTuple.copy.deepcopy, list(x) / slicing large lists, pandas operations that copy; use views (memoryview, NumPy views) and in-place ops where safe.re.compile inside a function called in a loop (module-level constant instead), building lookup dicts per call.f.read() on large files -> iterate lines or chunks.List<Integer>, Stream<Integer>, Map<Long, ...> in hot loops; use IntStream/primitive arrays or a primitive-collections library. Kotlin: IntArray vs Array<Int>, nullable Int? boxes.StringBuilder (single-expression + is fine).Pattern.compile per call (also hidden in String.split/replaceAll with regex), new ObjectMapper per request; make them static/shared (both are thread-safe once configured).ArrayList/HashMap when known.asSequence()) avoid intermediate lists for long chains; inline higher-order functions avoid lambda objects.go build -gcflags=-m output: returning pointers to locals, values stored in interfaces, closures capturing variables, slices/maps of unknown size. Return values instead of pointers where small; keep data on the stack.any/interfaces in hot code (including fmt and loggers); use typed APIs.fmt.Sprintf for simple conversions -> strconv.Itoa/strconv.AppendInt, strings.Builder.[]byte <-> string conversions in loops copy each time; stay in one representation (bytes package functions, strings.Builder).append growth - make([]T, 0, n) when n is known; same for make(map[K]V, n).sync.Pool for reusable buffers on hot paths (reset before reuse; don't pool huge or rarely used objects).## Findings (hot paths only)
<stack detected; which paths were treated as hot and why>
- <file:line> [closure] ... -> ...
- <file:line> [boxing] ... -> ...
## Rewritten
<code>
## Verify
<stack-specific benchmark/profile to compare allocations before and after,
e.g. BenchmarkDotNet [MemoryDiagnoser] Allocated/Gen0, go test -benchmem allocs/op, JMH -prof gc>
benchmark-setup) - guesses mislead, and JITs/compilers already remove some allocations."Why does this allocate so much", "reduce GC pressure in this handler", "find boxing/closures here", "why does this escape to the heap", "cut allocations in this hot loop". Pairs with benchmark-setup, gc-pressure-auditor, and hotpath-profiler-assistant.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
TypeScript, JavaScript, Python, Go, Java, Kotlin, .NET, C#
/ai-dev-toolkit:memory-allocation-analyzerfrom AI for Developers Toolkit
npx claudepluginhub stefanthecode/ai-for-developers --plugin ai-dev-toolkit45 skills in this plugin
/api-endpoint-scaffolderScaffold HTTP API endpoints in any stack - ASP.NET Core Minimal APIs or controllers, Express, Fastify, NestJS, FastAPI, Django REST Framework, Spring Boot controllers, Go net/http, chi, Gin - one feature per endpoint (REPR style) with request validation, typed responses, route grouping, auth, and OpenAPI metadata. Use this skill whenever the user wants to add an endpoint or route, convert controllers to minimal APIs, structure routes or routers, set up endpoint groups, TypedResults, route handlers, request DTOs/schemas (zod, Pydantic, Bean Validation, binding tags), or asks "how do I add an endpoint / structure my API routes". Always use this skill for endpoint scaffolding; it generates a complete, validated endpoint that matches the project's conventions./architecture-test-generatorGenerate architecture tests / fitness functions that fail the build when architectural rules are violated - layer dependencies, module boundaries, cycles, naming, and visibility conventions - in any stack: NetArchTest or ArchUnitNET (.NET), ArchUnit or Konsist (Java/Kotlin), dependency-cruiser or eslint-plugin-boundaries (TypeScript/JavaScript), import-linter (Python), go-arch-lint or depguard (Go). Use this skill whenever the user wants architecture tests, to enforce layering or the dependency rule, dependency rules as tests, import rules, forbidden imports, no circular dependencies, naming conventions, fitness functions, or asks "how do I stop people breaking the architecture / enforce my layers / keep modules from importing each other". Always use this skill for architecture-test requests; it generates rules matching the project's real structure./async-await-auditorAudit async and concurrent code in any language for correctness and performance bugs - C#/.NET (async/await, Task), JavaScript/TypeScript (Promises, async/await), Python (asyncio), Java/Kotlin (CompletableFuture, virtual threads, coroutines), Go (goroutines, channels, context), Rust (tokio/async). Use this skill whenever the user shares async or concurrent code, or asks about deadlocks, hangs, blocking calls, .Result/.Wait(), async void, ConfigureAwait, floating or unhandled promises, await in a loop vs Promise.all, blocking the event loop, forgotten await, asyncio.gather/TaskGroup, CompletableFuture.join, virtual thread pinning, goroutine leaks, context cancellation, WaitGroup/errgroup, holding a lock across .await, fire-and-forget tasks, cancellation tokens, or "why does my async code hang". Always use this skill for async/concurrency reviews instead of answering from memory; it applies a fixed checklist and rewrites the code./authorization-setupDesign API authorization in any stack - policy-based, role-based, claims/permission-based, and resource-based (ownership) checks. Covers ASP.NET Core policies and AuthorizationHandler, NestJS guards, Express middleware and CASL, FastAPI dependencies/scopes, Django and DRF permission classes, Spring Security (@PreAuthorize, SecurityFilterChain), Go middleware, and Casbin/OPA. Use this skill whenever the user wants authorization policies, role/claim/permission checks, RBAC/ABAC, custom authorization rules, resource-based authorization, IDOR protection, "deny by default", or asks "how do I authorize this / policy vs role / restrict this endpoint to X / stop users seeing other users' data". Always use this skill for authorization requests; it generates policies, handlers, and endpoint wiring./benchmark-setupSet up correct micro-benchmarks in any stack and interpret the results - BenchmarkDotNet (.NET), JMH (Java/Kotlin), pytest-benchmark / pyperf (Python), Vitest bench / tinybench / mitata (JavaScript/TypeScript), Go testing.B + benchstat, Rust criterion. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations or functions, set up a benchmark harness, or asks "which is faster", "benchmark these two functions", "how do I benchmark this", "is this optimization worth it", or "interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks, avoids the classic pitfalls, and explains the numbers./caching-strategy-setupAdd the right caching to an app in any stack - in-process, distributed (Redis/Valkey/Memcached), two-level, or HTTP/output caching - with correct keys, expiration, stampede protection, and invalidation. Covers HybridCache / IMemoryCache / IDistributedCache / output caching in .NET, lru-cache / keyv / cache-manager / ioredis in Node, functools / cachetools / redis-py / Django cache in Python, Spring Cache with Caffeine or Redis in Java/Kotlin, and ristretto / groupcache / singleflight / go-redis in Go. Use this skill whenever the user wants caching, to cache a query/response, Redis caching, @Cacheable, lru_cache, HybridCache, cache-aside, output caching, or asks "how do I cache this / add caching / avoid cache stampede / invalidate this cache". Always use this skill for caching requests; it picks the right layer and wires expiration + invalidation correctly.Other plugins' skills for the same job