一键导入
project-api
Auto-generates and maintains project API documentation. Extracts classes, functions, exports from code. Self-healing, auto-installing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Auto-generates and maintains project API documentation. Extracts classes, functions, exports from code. Self-healing, auto-installing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Fast symbol lookup for large codebases. Use BEFORE reading files or spawning search agents to locate where a class/function/method is defined and what references it. Backed by an incremental SQLite + universal-ctags index, scoped per project. Answers "where is X?" in milliseconds instead of reading thousands of files.
Safer alternative to sed -i / perl -i / awk -i inplace for mass file edits. Use whenever you need to find-and-replace across multiple files, rename a symbol project-wide, bump a version string, or apply a regex transform to many files. A PreToolUse hook automatically blocks in-place sed/perl/awk to prevent accidental file corruption — use this skill instead.
AI-powered context persistence for Claude Code — manages user memories, notes, reminders, and conversation summaries via local LLM hooks and SQLite. Use whenever the user mentions remembering/forgetting facts, taking notes, setting reminders, or asks recall questions ("recuerda que...", "olvida que...", "anota...", "borra la nota...", "avísame...", "recuérdame...", "cancela el recordatorio...", "qué recuerdas?", "muestra mis notas", "show my reminders", "remember that...", "forget...", "take note...", "remind me...", "do you remember...?"). Runs entirely in background via hooks; this skill defines the behavior rules and recall commands Claude must follow when interacting with it.
Rules for creating ASCII art diagrams with Unicode box-drawing characters. Covers boxes, trees, flow charts, and visual representations.
Verification-first coding practices. Read before edit, grep before assume, verify API names, safe refactoring with reference checks. Never blame external factors.
Auto-generates and maintains project structure documentation. Self-healing, auto-installing. Query structure anytime without manual updates.
| name | project-api |
| description | Auto-generates and maintains project API documentation. Extracts classes, functions, exports from code. Self-healing, auto-installing. |
| license | MIT |
| compatibility | opencode |
| metadata | {"type":"documentation","output":".claude/api.md","scope":"all-codebases"} |
Step 1: Check if API file exists:
test -f .claude/api.md && echo "exists" || echo "missing"
Step 2: If "missing" or outdated, generate it using the generation script below.
Step 3: Verify:
head -50 .claude/api.md
When to auto-install: First session in project, after major code changes, or when API seems outdated.
This skill automatically generates and maintains a .claude/api.md file that documents the project's public API: classes with their methods, inheritance hierarchy, constructor parameters, and function signatures.
Philosophy: "Know the API before you code" - instant reference without reading all source files.
Output location: .claude/api.md
bash -c 'cat > .claude/api.md << API_EOF
# Project API Reference
Generated: $(date +%Y-%m-%d)
---
## Class Hierarchy
$(grep -rn "extends" --include="*.js" --include="*.ts" . 2>/dev/null | grep -v node_modules | grep -v dist | grep "class.*extends" | sed "s/.*class \([A-Za-z]*\) extends \([A-Za-z]*\).*/\2 → \1/" | sort | uniq)
---
## Classes with Methods
$(for file in $(find . -name "*.js" -type f 2>/dev/null | grep -v node_modules | grep -v dist | sort); do
classes=$(grep -n "^export class\|^class " "$file" 2>/dev/null | head -5)
if [ -n "$classes" ]; then
echo ""
echo "### $(basename $file)"
echo "\`$file\`"
echo ""
# Extract each class with its methods
grep -n "^export class\|^class " "$file" 2>/dev/null | while read classline; do
classname=$(echo "$classline" | sed "s/.*class \([A-Za-z_]*\).*/\1/")
linenum=$(echo "$classline" | cut -d: -f1)
extends=$(echo "$classline" | grep -o "extends [A-Za-z_]*" | sed "s/extends //" || echo "")
if [ -n "$extends" ]; then
echo "#### $classname (extends $extends)"
else
echo "#### $classname"
fi
echo ""
# Get constructor signature
constructor=$(awk "NR>=$linenum && NR<=$((linenum+50))" "$file" 2>/dev/null | grep -m1 "constructor(" | sed "s/^[[:space:]]*//" | head -1)
if [ -n "$constructor" ]; then
echo "**Constructor:** \`$constructor\`"
echo ""
fi
# Get methods (public ones, first 15)
echo "**Methods:**"
awk "NR>=$linenum && NR<=$((linenum+300))" "$file" 2>/dev/null | grep -E "^[[:space:]]+(async\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*\(" | grep -v "constructor\|^[[:space:]]*//\|^[[:space:]]*\*" | sed "s/^[[:space:]]*/- \`/" | sed "s/$/\`/" | head -15
echo ""
done
fi
done | head -500)
---
## Exported Functions
$(grep -rn "^export function\|^export async function\|^export const.*=.*=>" --include="*.js" --include="*.ts" . 2>/dev/null | grep -v node_modules | grep -v dist | while read line; do
file=$(echo "$line" | cut -d: -f1)
content=$(echo "$line" | cut -d: -f3-)
# Extract function name and params
if echo "$content" | grep -q "^export function\|^export async function"; then
sig=$(echo "$content" | sed "s/export \(async \)\{0,1\}function //" | sed "s/{.*//" | tr -d "\n")
echo "- \`$sig\` → $file"
elif echo "$content" | grep -q "^export const.*=>"; then
name=$(echo "$content" | sed "s/export const \([a-zA-Z_]*\).*/\1/")
echo "- \`$name\` → $file"
fi
done | head -50)
---
## Getters and Setters
$(grep -rn "^\s*get \|^\s*set " --include="*.js" --include="*.ts" . 2>/dev/null | grep -v node_modules | grep -v dist | grep -v "\.test\.\|\.spec\." | sed "s/^[[:space:]]*//" | awk -F: '{
file=$1;
prop=$3;
gsub(/^[[:space:]]*/, "", prop);
gsub(/[[:space:]]*\{.*/, "", prop);
print "- `" prop "` → " file
}' | sort | uniq | head -40)
---
## Event Names / Constants
$(grep -rn "addEventListener\|on[A-Z][a-z]*.*=" --include="*.js" . 2>/dev/null | grep -v node_modules | grep -oE "'[a-z]+'" | sort | uniq -c | sort -rn | head -15 | awk '{print "- " $2 " (" $1 " uses)"}')
---
## Common Patterns
### Frequently Used Properties
$(grep -rn "this\.\(width\|height\|x\|y\|id\|name\|value\|type\|status\)" --include="*.js" --include="*.ts" . 2>/dev/null | grep -v node_modules | grep -oE "this\.[a-zA-Z_]+" | sed "s/this\.//" | sort | uniq -c | sort -rn | head -15)
---
## Entry Points
$(find . -maxdepth 3 -name "index.js" -type f 2>/dev/null | grep -v node_modules | while read f; do
echo "### $f"
grep "^export" "$f" 2>/dev/null | head -20
echo ""
done)
---
## Quick API Lookup
| Class | File | Extends | Key Methods |
|-------|------|---------|-------------|
$(grep -rn "^export class" --include="*.js" . 2>/dev/null | grep -v node_modules | grep -v dist | head -25 | while read line; do
file=$(echo "$line" | cut -d: -f1)
classinfo=$(echo "$line" | cut -d: -f3-)
classname=$(echo "$classinfo" | sed "s/.*class \([A-Za-z_]*\).*/\1/")
extends=$(echo "$classinfo" | grep -o "extends [A-Za-z_]*" | sed "s/extends //" || echo "-")
methods=$(grep -A 100 "class $classname" "$file" 2>/dev/null | grep -E "^[[:space:]]+(async\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*\(" | grep -v constructor | head -3 | sed "s/(.*//" | tr -d " \t" | tr "\n" ", " | sed "s/,$//")
echo "| $classname | $(basename $file) | ${extends:--} | ${methods:--} |"
done)
API_EOF'
cat .claude/api.md
grep -A 20 "#### ClassName" .claude/api.md
grep -rn "methodName(" --include="*.js" . | grep -v node_modules
grep -A 30 "class ClassName" src/file.js | grep -m1 "constructor("
grep -A 200 "class ClassName" src/file.js | grep -E "^\s+(async\s+)?[a-zA-Z_].*\(" | head -20
Regenerate API when:
if [ -f .claude/api.md ]; then
file_age=$(( ($(date +%s) - $(stat -f %m .claude/api.md 2>/dev/null || stat -c %Y .claude/api.md 2>/dev/null)) / 86400 ))
echo "API file is $file_age days old"
[ $file_age -gt 7 ] && echo "OUTDATED - regenerate"
else
echo "MISSING - generate now"
fi
# Before using any method
grep -rn "methodName" --include="*.js" . | grep -v node_modules | head -3
Before using any API:
.claude/api.md for correct method name# Save API discovery to memory
sqlite3 .claude/memory.db "INSERT INTO memories (type, subject, content, importance, file_refs) VALUES ('api', 'ClassName.methodName', 'Correct usage: ...', 4, 'src/file.js')"
API SKILL QUICK REFERENCE
GENERATE
Full: Run generation script above
Quick: grep "^export class" --include="*.js" -rn .
QUERY
View: cat .claude/api.md
Class: grep -A 20 "#### ClassName" .claude/api.md
Method: grep -rn "methodName(" --include="*.js" .
VERIFY
Exists: grep -rn "class X" . | grep -v node_modules
Method: grep -A 50 "class X" file.js | grep "methodName"
Params: grep -A 30 "class X" file.js | grep "constructor("
PATTERNS
Classes: grep "^export class"
Functions: grep "^export function"
Getters: grep "^\s*get "
Setters: grep "^\s*set "