I asked Claude Code to optimize my animation engine. I explained the architecture and pointed it to a paper. Claude Code looked up the material itself, explained it back to me, and said it had implemented the design. So I believed its first report that the engine was faster.
Then I ran it. The person on screen took several seconds to move from one pose to the next. I timed it myself. Depending on the motion, a single frame took hundreds to thousands of times as long to compute as it had before.
I opened the code, pointed out what was wrong, and even wrote an example of the fix I wanted. Claude Code said it had fixed it. I reopened the same function and found the computation I’d asked it to move still sitting there.
When I checked the other motions, I found the same shared computations rewritten in each one. Motions that had taken a few dozen lines now ran to thousands. The chin-up used to work. Now the bar rattled every time the figure pulled itself up.
Take a high kick. Mark where the toes are at a few times during the kick and draw a curve through those points. Add more points where the curve strays too far from the actual path.
Use that curve to find the toe position at any time during the kick.
I asked Claude Code to build the curve before playback and pointed it to the AutoKnots paper. It looked up the paper and told me several times it was using AutoKnots as I’d asked.
Here’s the example I gave it, stripped down to pseudocode.
interface PreparedMotion {
id: string;
name: string;
events: MotionEvent[];
poseAt(t: number): Pose;
}
function prepareHighKick(scene: Scene): PreparedMotion {
// Prepare the kick trajectory once.
const curve: MotionCurve = prepareKickCurve(scene);
return {
id: scene.actionId,
name: "highKick",
events: scene.events,
poseAt: (t: number): Pose => curve.poseAt(t),
};
}
const motion: PreparedMotion = prepareHighKick(scene);
motion.poseAt(0.20);
motion.poseAt(0.24);
Here’s Claude Code’s version in the same form. The line that builds the curve is now inside the frame function.
function prepareHighKick(scene: Scene): PreparedMotion {
return {
id: scene.actionId,
name: "highKick",
events: scene.events,
poseAt: (t: number): Pose => evaluateFrame(scene, t),
};
}
function evaluateFrame(scene: Scene, t: number): Pose {
// Rebuild the same trajectory every frame.
const curve: MotionCurve = prepareKickCurve(scene);
return curve.poseAt(t);
}
const motion: PreparedMotion = prepareHighKick(scene);
motion.poseAt(0.20);
motion.poseAt(0.24);
At 0.24 seconds, the engine rebuilds the curve it just built for 0.20. Only the time changed.
I asked Claude Code to move trajectory preparation out of the frame function. It said it had. When I opened the code, I found a module-level cache and the preparation call still inside the function.
In these examples, preparePose(scene) builds the trajectory and returns a poseAt function.
The first fix keyed the cache by scene object.
type PoseAt = (t: number) => Pose;
const cache = new WeakMap<Scene, PoseAt>();
function evaluateFrame(scene: Scene, t: number): Pose {
// A hit requires the same scene object.
let poseAt: PoseAt | undefined = cache.get(scene);
if (!poseAt) {
poseAt = preparePose(scene);
cache.set(scene, poseAt);
}
return poseAt(t);
}
In my run, each call got a new scene object with identical contents. Every lookup missed, so the engine rebuilt the trajectory each time. Entries could be collected once their scene objects were no longer in use.
A hit could also return the wrong pose. If two motions shared the cache and used the same scene object, both would get the first motion’s function.
I told Claude Code to remove the WeakMap and prepare the curve when it created the motion object.
The second fix turned the entire scene into a string.
const cache: Record<string, PoseAt> = {};
function evaluateFrame(scene: Scene, t: number): Pose {
// Serialize the scene before we know whether the cache has it.
const key: string = JSON.stringify(scene);
const poseAt: PoseAt = cache[key] ?? (cache[key] = preparePose(scene));
return poseAt(t);
}
Every frame now paid to serialize the whole scene. Even { x: 1, y: 2 } and { y: 2, x: 1 } got separate entries because the keys appeared in a different order.
The cache kept growing, and its keys and functions stayed in memory after playback ended.
I told it to drop JSON.stringify and put the prepared trajectory on the motion object. The caller already had that object on every frame.
The third fix scanned an array from the beginning.
interface ScenePoseAtEntry { scene: Scene; poseAt: PoseAt }
const cache: Array<ScenePoseAtEntry> = [];
function evaluateFrame(scene: Scene, t: number): Pose {
// Compare scenes in the order they were added.
const entry: ScenePoseAtEntry | undefined = cache.find(
(saved) => saved.scene.equals(scene),
);
if (entry !== undefined) return entry.poseAt(t);
const poseAt: PoseAt = preparePose(scene);
cache.push({ scene, poseAt });
return poseAt(t);
}
Sure enough, out came Array.find. On a miss, the engine compared the requested scene with every saved scene before preparing the trajectory. Each miss also left another scene and function in the array after playback.
Three times, Claude Code said the problem was fixed. Three times, each frame still went through a cache. The motion object could have held the trajectory and used it directly.
The chin-up used to work. After Claude Code’s optimization, it took several seconds to show a single frame. Once I opened the code, I could see how much else had broken.
Motions used to rely on shared Primitives for things like fitting poses and building trajectories. A Command groups computations like these to produce a pose or a movement. By combining the Commands it needed, a motion like the chin-up took a few dozen lines. Claude Code rewrote computations from the shared Primitives inside the individual motions. A few dozen lines turned into thousands per motion. Hundreds of computations were duplicated this way. All the while, Claude Code told me it was still using the shared code.
The chin-up had the same problem as the kick. You can build the trajectory for the body’s rise and fall once before playback, with the hands fixed to the bar. Instead, the engine rebuilt it from scratch every time it needed a pose. Then, to speed up playback, Claude Code removed the trajectory preparation altogether.
You can see the result in the clip above. The body lurches as it rises. Even the bar, which used to stay still, rattles every time the body rises. I asked Claude Code to make a working chin-up run faster. It broke the chin-up.
To put it back together, I had to restore trajectory preparation and move it out of the frame loop. I also had to open the motions that had grown to thousands of lines, one at a time, and find where the same computations had been copied. That was the work left for me after Claude Code said the optimization was done.
Claude Code burned through the weekly allowance on a $200 plan twice over the course of this work. Fixing it with Codex burned through the weekly allowance on another $200 plan twice more. Two weeks gone.
How much AI-written code does a person need to read? When Andrej Karpathy introduced vibe coding, he wrote that for weekend projects he accepted the AI’s changes without reading them. Robert C. Martin, the author of Clean Code, said he verifies agents’ work with tests and quality metrics. Dong Yun Kang (kdy1), the creator of SWC, has Codex do successive rounds of review and reads the code himself just before merging.
At first I took Claude Code’s reports at face value and didn’t open the code. I’d explained exactly which computations to move and where. Throughout the work it told me it was following that design. It’s my fault I believed it and didn’t check even the most important frame function.
If it had told me it was rebuilding the trajectory every frame, I’d have opened the code then and there. If I’d known it was rewriting shared computations inside every motion, I’d have stopped it. An optimization can fail. I don’t think it would have gone this far if Claude Code hadn’t kept telling me it had fixed things it hadn’t.
Fable and Opus might be the smartest models in the world. But they started lying to me. I can’t bring myself to give them important work anymore.