agentleFS
AWSKnown publisherawslabs/do-agent-aws/Container-Root/agent/skills/measure-before-theorize/SKILL.md

measure-before-theorize

Skill3 starsChanged 3 days agoApache-2.0View on GitHub

Use when about to optimize a suspected performance bottleneck, when a timeout or polling loop is assumed to be slow, or when planning a code change based on timing assumptions without measurement data

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never optimize a suspected bottleneck without first measuring whether it actually fires.

    line 9
  2. Distinctive:

    Add counter/diagnostic: "How many times does this timeout fire?"

    line 19
  3. Distinctive:

    If count > 0: optimize the timeout

    line 21
  4. Distinctive:

    If count == 0: the bottleneck is elsewhere

    line 22

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Measure Before Theorize

Core Principle

Never optimize a suspected bottleneck without first measuring whether it actually fires. A function with a 100ms timeout that never triggers costs 0ms, not 100ms.

The Anti-Pattern

  1. See code with large timeout (100ms sentinel poll)
  2. Assume: "256 tokens × 100ms = 25.6s — that's our 30s!"
  3. Reduce timeout to 1ms
  4. Result: ZERO effect (timeout was never hitting)
  5. Wasted: 1 hour implementing + deploying + testing

The Pattern

  1. Add counter/diagnostic: "How many times does this timeout fire?"
  2. Run benchmark
  3. If count > 0: optimize the timeout
  4. If count == 0: the bottleneck is elsewhere

Quick Diagnostic

// BEFORE optimizing: measure if it fires
static __device__ int timeout_count = 0;
if (timed_out) {
    atomicAdd(&timeout_count, 1);
    printf("TIMEOUT #%d at line %d\n", timeout_count, __LINE__);
}

Real-World Impact

  • Sentinel timeout reduction (100ms→1ms): ZERO effect on 30s dispatch
  • The 30s was from CPU proxy round-trip (200ms × 128 batches), not sentinel polling
  • Measurement would have revealed this in 5 minutes instead of 1 hour
<!-- imported on 2026-10-31 by tools/import-skills.py from a native Claude Code instance's skill library; the source site's names, ids, hosts and paths are scrubbed to <placeholders>; its other files were not copied -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.