Chrysopoeia

From pjt222/agent-almanac · View interactive version

Chrysopoeia is an AI agent skill from the GitHub repository pjt222/agent-almanac. Extract maximum value from existing code — performance optimization, API surface refinement, and dead weight elimination. The art of turning base code into gold through systematic identification and amplification of value-bearing patterns. Use when optimizing a working but sluggish codebase, refinin

How to use this skill

Skill file

Chrysopoeia

Pull max value from code → find gold (high-val), lead (heavy), dross (dead). Amplify gold, transmute lead, purge dross.

Use When

In

Do

Step 1: Assay — Classify

Classify every element by value.

  1. Define value metric from In
  2. Inventory elements (fns, modules, exports, deps)
  3. Classify each:
Value Classification:
+--------+---------------------------------------------------------+
| Gold   | High value, well-designed. Amplify and protect.         |
| Silver | Good value, minor imperfections. Polish.                |
| Lead   | Functional but heavy — poor performance, complex API.   |
|        | Transmute into something lighter.                       |
| Dross  | Dead code, unused exports, vestigial features.          |
|        | Remove entirely.                                        |
+--------+---------------------------------------------------------+
  1. Perf work → profile first:
  1. Produce Assay Report: element-by-element w/ evidence

→ Every element classified w/ evidence. Gold marked protect. Lead ranked by impact.

If err: No profiler → static analysis: cyclomatic complexity, dep count, size as proxies. Huge codebase → critical path first.

Step 2: Refine — Amplify Gold

Protect + enhance highest-value elements.

  1. Each Gold:
  1. Each Silver:
  1. Do NOT modify Gold/Silver behavior → polish only

→ Gold + Silver better tested, documented, protected. No behavior change, quality up.

If err: "Gold" reveals hidden problems → reclassify. Honest > protect flawed.

Step 3: Transmute — Lead → Gold

Convert heavy elements to optimized equivalents.

  1. Rank Lead by impact (highest resource first)
  2. Each Lead → pick strategy:
  1. Apply + measure:
  1. Valid. behavior identical post-transmute

→ Measurable metric improvement. Each transmuted > Lead predecessor, same behavior.

If err: Lead resists opt in current interface → interface itself = problem. Sometimes transmute = change caller, not impl.

Step 4: Purge — Remove Dross

Kill dead weight systematically.

  1. Each Dross → valid. truly unused:
  1. Remove confirmed:
  1. Valid. nothing breaks post-removal (tests)
  2. Doc what + why (commit msgs, not code)

→ Codebase lighter. Bundle/dep count/volume measurably down. Tests pass.

If err: Removal breaks → wasn't dross → reclassify. Dynamic refs hide usage → temp logging before delete to confirm no runtime access.

Step 5: Verify — Weigh Gold

Measure overall improvement.

  1. Run same benchmarks as Step 1
  2. Before/after on metric
  3. Doc results:

→ Measurable, documented metric improvement. Codebase demonstrably more valuable.

If err: Marginal improvement → orig code better than assumed. Doc learning → knowing code near-optimal = valuable.

Check

Traps

→

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.