chrysopoeia
について
クリソペイアは、機能している既存のコードベースを全面的な書き直しなしに最適化・改良するためのClaudeスキルです。パフォーマンスを体系的に向上させ、APIを整理し、デッドコードを除去してバンドルサイズとメモリフットプリントを削減します。動作が鈍い、または煩雑なコードを、より効率的で保守性の高い状態に磨き上げるためにご利用ください。
クイックインストール
Claude Code
推奨npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/chrysopoeiaこのコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします
ドキュメント
Chrysopoeia
Extract max value from existing code. Identify gold (high-value, well-designed), lead (resource-heavy, poorly optimized), dross (dead weight). Amplify gold, transmute lead, remove dross.
When Use
- Optimizing working but sluggish codebase for performance
- Refining API surface with accumulated cruft
- Reducing bundle size, memory footprint, startup time
- Prepping code for open-source release (extract valuable core)
- Code works correctly but doesn't shine — needs polish, not rewrite
Inputs
- Required: Codebase or module to optimize (file paths)
- Required: Value metric (performance, API clarity, bundle size, readability)
- Optional: Profiling data or benchmarks showing current performance
- Optional: Budget or target (e.g., "reduce bundle by 40%", "sub-100ms response")
- Optional: Constraints (can't change public API, must maintain backward compat)
Steps
Step 1: Assay — Classify the Material
Classify every element by value contribution.
- Define value metric from Inputs (performance, clarity, size, etc.)
- Inventory elements (functions, modules, exports, dependencies)
- 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. |
+--------+---------------------------------------------------------+
- Performance optimization: profile first.
- Identify hot paths (where time spent)
- Identify cold paths (rarely-run code, may be dross)
- Measure memory allocation patterns
- Produce Assay Report: element-by-element classification with evidence
Got: Every significant element classified with evidence. Gold elements identified for protection. Lead elements prioritized by impact.
If fail: No profiling tools? Use static analysis — function complexity (cyclomatic), dependency count, code size as proxies. Codebase too large? Focus critical path first.
Step 2: Refine — Amplify the Gold
Protect and enhance highest-value elements.
- Each Gold element:
- Ensure comprehensive tests (most valuable assets)
- Document interface clearly if not already
- Consider extraction as reusable module
- Each Silver element:
- Apply targeted improvements (better naming, clearer types, minor optimizations)
- Bring test coverage to Gold level
- Resolve minor code smells without restructuring
- Do not modify Gold/Silver behavior. Only improve polish and protection.
Got: Gold and Silver elements better tested, documented, protected. No behavioral changes. Quality improvements only.
If fail: "Gold" element reveals hidden problems under closer inspection? Reclassify. Honest about value beats protecting flawed code.
Step 3: Transmute — Convert Lead to Gold
Transform heavy, inefficient elements into optimized equivalents.
- Prioritize Lead elements by impact (highest resource consumption first)
- Each Lead element, choose transmutation strategy:
- Algorithm optimization: Replace O(n^2) with O(n log n). Eliminate redundant computation.
- Caching/memoization: Store expensive results requested repeatedly
- Lazy evaluation: Defer computation until results actually needed
- Batch processing: Combine many small operations into fewer large ones
- Structural simplification: Reduce cyclomatic complexity, flatten deep nesting
- Apply strategy. Measure improvement.
- Before/after benchmarks for performance changes
- Before/after line counts for complexity changes
- Before/after dependency counts for coupling changes
- Verify behavioral equivalence after each transmutation.
Got: Measurable improvement on target value metric. Each transmuted element performs better than Lead predecessor. Identical behavior maintained.
If fail: Lead element resists optimization within current interface? Interface itself may be problem. Transmutation may require changing how element is called, not just implementation.
Step 4: Purge — Remove the Dross
Eliminate dead weight.
- Each Dross element, verify truly unused:
- Search all references (grep, IDE find-usages)
- Check dynamic references (string-based dispatch, reflection)
- Check external consumers (if library)
- Remove confirmed dross:
- Delete dead code, unused exports, vestigial features
- Remove unused dependencies from package manifests
- Clean up config for removed features
- Verify nothing breaks after each removal (run tests)
- Document what removed and why (commit messages, not code)
Got: Codebase lighter. Bundle size, dependency count, or code volume measurably reduced. All tests pass.
If fail: Removing element breaks something? Wasn't dross. Reclassify. Dynamic references make usage hard to verify? Add temp logging before deletion to confirm no runtime access.
Step 5: Verify — Weigh the Gold
Measure overall improvement.
- Run same benchmarks/metrics from Step 1
- Compare before/after on target value metric
- Document chrysopoeia results:
- Elements refined (Gold/Silver improvements)
- Elements transmuted (Lead → Gold, with measurements)
- Elements purged (Dross removed, with size/count impact)
- Overall metric improvement (e.g., "47% faster", "32% smaller bundle")
Got: Measurable, documented improvement on target value metric. Codebase demonstrably more valuable.
If fail: Overall improvement marginal? Original code may have been better than assumed. Document learnings — knowing code is near-optimal is itself valuable.
Checks
- Assay report classifies all significant elements with evidence
- Gold elements have comprehensive tests and documentation
- Lead transmutations show measurable before/after improvement
- Dross removal verified with reference checks before deletion
- All tests pass after each stage
- Overall improvement measured and documented
- No behavioral regressions introduced
- Constraints from Inputs satisfied
Pitfalls
- Premature optimization: Optimizing without profiling. Measure first. Optimize hot paths.
- Polishing dross: Effort on code that should be deleted. Classify before refining.
- Breaking Gold: Optimization that degrades best code. Gold should only get better, never worse.
- Unmeasured claims: "Feels faster" is not chrysopoeia. Every improvement quantified.
- Optimizing cold paths: Effort on code that runs once at startup when bottleneck is request loop.
See Also
athanor— Full four-stage transformation when chrysopoeia reveals code needs restructuring, not just optimizationtransmute— Targeted conversion when Lead element needs paradigm shiftreview-software-architecture— Architecture-level evaluation complementing code-level chrysopoeiareview-data-analysis— Data pipeline optimization parallels code optimization
GitHub リポジトリ
関連スキル
executing-plans
デザインexecuting-plansスキルは、完全な実装計画があり、それを管理されたバッチでレビューチェックポイントを設けながら実行する場合に使用します。このスキルは計画を読み込んで批判的にレビューした後、小さなバッチ(デフォルトは3タスク)でタスクを実行し、各バッチの間に進捗状況を報告してアーキテクトのレビューを受けます。これにより、品質管理チェックポイントが組み込まれた体系的な実装が保証されます。
requesting-code-review
デザインこのスキルは、コードレビュアーサブエージェントを起動し、処理を進める前に要件に対してコード変更を分析します。タスク完了後、主要な機能の実装後、またはmainブランチへのマージ前などに使用すべきです。このレビューは、現在の実装と元の計画を比較することで、問題を早期に発見するのに役立ちます。
connect-mcp-server
デザインこのスキルは、開発者がHTTP、stdio、またはSSEトランスポートを使用してMCPサーバーをClaude Codeに接続するための包括的なガイドを提供します。GitHub、Notion、カスタムAPIなどの外部サービスを統合するためのインストール、設定、認証、セキュリティについて解説しています。MCP統合のセットアップ、外部ツールの設定、またはClaudeのModel Context Protocolを扱う際にご利用ください。
web-cli-teleport
デザインこのスキルは、タスク分析に基づいて開発者がClaude Code WebとCLIインターフェースの選択を支援し、これらの環境間でのシームレスなセッションテレポーテーションを可能にします。Web、CLI、モバイル環境を切り替える際のセッション状態とコンテキストを管理することで、ワークフローを最適化します。様々な段階で異なるツールを必要とする複雑なプロジェクトにご活用ください。
