Autonomous Optimization with Claude Code

Optimize your infrastructure autonomously every day with Claude Code and Polar Signals

Author:Frederic Branczyk
Frederic Branczyk

Polar Signals Cloud has been an incredible tool for collecting and storing continuous profiling data for CPU, Memory and GPUs. It is used by some of the most sophisticated engineering teams, analyzing the profiling data with visualization like Flamegraphs and turning that knowledge into code changes.

A few weeks ago, we announced OAuth for AI Agents, enabling our users to use OAuth for authenticating their Claude Code, Cursor, or any other coding LLM with the Polar Signals MCP. That alone provides a nicer experience, it means users don't ever need to copy long-lived authentication tokens around.

Today we want to dive into one of the more exciting use cases OAuth for AI Agents enabled: Using the Polar Signals MCP from Claude Code Web/Desktop, and more specifically we can now make use of it in the "Routines" feature of Claude Code.

Every code base has optimizations that just no one has gotten around to doing, let's fix that and remove unnecessary resource waste!

Creating your routine

First make sure you have the Polar Signals Cloud connector setup. The MCP url is https://api.polarsignals.com/api/mcp, and use the advanced OAuth configuration and use the polarsignals-mcp-claude-desktop client ID.

Claude Connectors

Routines allow executing a prompt on a schedule, or on some particular trigger. In this setup, we'll be focusing on running it on a schedule, but it doesn't take much to imagine other use cases where other triggers might be interesting.

Head over to claude.ai/code/routines

Claude Code Web Routines

And click "+ New routine"

New routine form for "Daily Perf Review & Optimization"

We called our routine "Daily Perf Review & Optimization". And our prompt:

Have a look at the profiling data in Polar Signals in the Production project and create a report analyzing the last day of data. Compare how it changed from the day before that.

If there are architectural changes that are likely to benefit the system as a whole write up a short paragraph on what that improvement is and why it would create a significant benefit due to what you learned from the profiling data.

If there is a significant finding that can improve our CPU usage by more than 1%, create a PR to improve it.

Results

Past routine runs

We've been running this routine for a couple of days now, and have seen everything from reducing allocations (resulting in a 20% improvements in one our workloads!), over choosing better hashing algorithms, to catching improvements in code that we checked in the day before. Autonomous performance optimizations are actually a reality!

If you too want to finally improve all those inefficiencies that you just haven't gotten around to in your code base, then sign up for a free 14-day trial of Polar Signals Cloud and get started today!

Keep up with Polar Signals

Receive new posts, product updates, and insights on performance engineering straight to your inbox.