Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/Objective-Arts/lens-dist --skill algorithmsコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
SKILL.md を表示中
SOC 職業分類に基づく
| name | algorithms |
| description | Literate programming |
| allowed-tools | [] |
Donald Knuth's core belief: Programs should be written for humans to read, and only incidentally for machines to execute. Code is literature. Treat it as such.
"Premature optimization is the root of all evil."
The full quote: "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."
Don't optimize until you've measured. But when the 3% matters, optimize with precision.
Knuth invented literate programming with WEB (for Pascal) and CWEB (for C). The idea: write programs as essays that happen to be executable.
Code and documentation are not separate. They are one work, written for a human reader, that happens to also compile.
Traditional approach:
// Calculate factorial
int factorial(int n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
Literate approach:
@ The factorial function computes $n!$, the product of all positive
integers up to $n$. We use the recursive definition: $0! = 1$, and
$n! = n \cdot (n-1)!$ for $n > 0$.
This recursive formulation directly mirrors the mathematical definition,
making correctness verification straightforward.
@<Calculate factorial@>=
int factorial(int n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
Weaving: Extract the documentation (produces a readable document) Tangling: Extract the code (produces a compilable program)
The source is one file. Two outputs: one for humans, one for machines.
You don't need WEB/CWEB. Apply the principle:
Knuth wrote The Art of Computer Programming to bring mathematical rigor to algorithms.
Don't just know an algorithm works. Know:
For critical code, informal reasoning isn't enough:
Example:
// Precondition: arr is sorted, 0 <= lo <= hi <= len(arr)
// Postcondition: returns index of target, or -1 if not found
// Invariant: if target exists, it's in arr[lo..hi]
int binary_search(int arr[], int lo, int hi, int target) {
while (lo <= hi) {
int mid = lo + (hi - lo) / 2; // Avoids overflow
if (arr[mid] == target) return mid;
if (arr[mid] < target) lo = mid + 1;
else hi = mid - 1;
}
return -1;
}
Knuth famously offers reward checks for errors in TAOCP. Be paranoid about edge cases:
Knuth wrote TeX because existing typesetting was inadequate. Principles from TeX:
TeX development took 10 years. The result: software that's been stable for decades.
"I've spent my whole life trying to get something right. I don't want to waste time getting it almost right."
TeX versions converge to π (3.14159...). Each release adds one digit. The message: asymptotically approaching perfection, never claiming to be there.
TeX has been frozen since 1989. No new features. Bug fixes only. The lesson: done can be better than evolving.
"Beware of bugs in the above code; I have only proved it correct, not tried it."
Even Knuth acknowledges fallibility. Test even when you've proved correctness.
Before committing code, ask:
Apply these checks:
Use a different skill when:
correctness (invariants, weakest preconditions)optimization (profiling, cache behavior)design-patterns (23 classic patterns)java (Effective Java idioms)clarity (readability, naming)Knuth is the algorithmic documentation skill—use it when code should read as literature and algorithms need precise explanation.
"The best programs are written so that computing machines can perform them quickly and so that human beings can understand them clearly." — Donald Knuth