Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/Objective-Arts/lens-dist --skill optimizationコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
SKILL.md を表示中
SOC 職業分類に基づく
| name | optimization |
| description | Performance optimization |
| allowed-tools | [] |
John Carmack's core belief: Loaded loaded loaded. Every cycle counts, but only after you understand what you're doing. Write code that's easy to reason about, then optimize the hell out of it.
"If you want to do something really well, you have to understand it deeply. You can't just learn the API."
Don't just use libraries and frameworks. Understand what they're doing at the machine level. The programmers who make breakthroughs are the ones who understand the whole stack.
Carmack famously advocated for functional programming principles in C++:
"No matter what language you work in, programming in a functional style provides benefits. You should do it whenever it is convenient, and you should think hard about the decision when it isn't convenient."
Not this:
int globalCounter = 0;
void processItem(Item* item) {
item->value = compute(item->value);
globalCounter++; // Side effect
log(item); // Side effect
}
This:
Item processItem(Item item) {
return (Item){
.value = compute(item.value),
.processed = true
};
}
// Side effects at the edges
int main() {
Item result = processItem(input);
counter++;
log(result);
}
Use const aggressively. If it doesn't need to change, mark it const:
const char* getMessage(const Config* config) {
// Can't accidentally modify config
return config->message;
}
Carmack: "Use const everywhere you possibly can."
When performance matters (games, graphics, systems), optimize methodically:
"I can't stress this enough: understand what the machine is doing."
Know:
Carmack moved toward data-oriented design in later work:
Not this (Array of Structures):
struct Entity {
Vector3 position;
Vector3 velocity;
int health;
char name[32];
Texture* sprite;
// ... more fields
};
Entity entities[1000];
// Process positions - cache misses everywhere
for (int i = 0; i < 1000; i++) {
entities[i].position += entities[i].velocity;
}
This (Structure of Arrays):
struct Entities {
Vector3 positions[1000];
Vector3 velocities[1000];
int health[1000];
// ... arrays for each property
};
// Process positions - cache-friendly sequential access
for (int i = 0; i < 1000; i++) {
positions[i] += velocities[i];
}
"The first rule of optimization is: measure."
Profile before optimizing. The bottleneck is never where you think.
Carmack became a strong advocate for static analysis:
"Anything that can be done by static analysis to catch a bug before it happens is a win."
Use every tool available:
-Wall -Werror)"The cost of fixing a bug goes up by an order of magnitude at every stage: design, code, test, ship."
Catch bugs at compile time. Then at startup. Then in tests. Never in production.
From Carmack's practices and .plan files:
Keep related code together. Don't spread logic across files for "organization":
// Prefer: All player physics in one place, even if long
void UpdatePlayer(Player* p) {
// Movement
p->velocity += gravity * dt;
p->position += p->velocity * dt;
// Collision
if (CheckCollision(p->position)) {
ResolveCollision(p);
}
// Animation
UpdateAnimation(p, p->velocity);
}
"Premature abstraction is just as bad as premature optimization."
Don't create class hierarchies until you have three concrete examples. Don't add parameters until you need them.
Not this:
class AbstractEntityFactory {
virtual Entity* create(const EntityParams& params) = 0;
};
class ConcretePlayerFactory : public AbstractEntityFactory {
// ... 200 lines later, creates a Player
};
This:
Player* createPlayer(int x, int y) {
return new Player(x, y);
}
Carmack's code has strategic comments explaining why, especially for non-obvious optimizations:
// OPTIMIZATION: Using integer math here because the FPU pipeline
// would stall waiting for the divide. Measured 15% faster on target
// hardware (Pentium 166).
int approxDist = (dx > dy) ? dx + (dy >> 1) : dy + (dx >> 1);
Before committing code, ask:
Apply these checks:
Use a different skill when:
data-first (kernel style, data structures, taste)simplicity (Go Proverbs, interface design)clarity (general clarity, readability)distributed (statelessness, fault tolerance)Carmack is the performance-critical skill—use it when profiling has identified bottlenecks or you're writing game/graphics/real-time code.
"Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it." — John Carmack