一键导入
jsharpener
JavaScript/TypeScript static analysis tool for call graphs, unused code detection (tree shaking), dependency analysis, and circular dependency detection
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
JavaScript/TypeScript static analysis tool for call graphs, unused code detection (tree shaking), dependency analysis, and circular dependency detection
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Protocol fuzzer script development using boofuzz framework. Use when creating network protocol fuzzers, defining protocol PDUs (Protocol Data Units), writing mutation-based fuzzing scripts, or contributing to the boofuzz project. Covers binary protocol definitions, session management, crash detection, and reporting findings.
Real-time browser debugging and interaction via WebSocket bridge server on localhost:3141
Guide for creating Claude Code skill documents with YAML frontmatter, instructions, examples, and reference implementations
C# static analysis tool for call graphs, unused code detection, impact analysis, HTML documentation generation, and Graphviz diagram export
UTF-8 JSON file I/O utilities to avoid Windows encoding issues (CP-1252 vs UTF-8)
Rust development patterns, project setup, CLI/TUI applications, error handling, and system integration
| name | JSharpener |
| description | JavaScript/TypeScript static analysis tool for call graphs, unused code detection (tree shaking), dependency analysis, and circular dependency detection |
JSharpener is a TypeScript Compiler API-based static analysis tool that analyzes JavaScript and TypeScript codebases to build call graphs, identify unused code, detect circular dependencies, and help with refactoring decisions.
C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js
Run with: node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" <command>
Note: If the executable is not available, rebuild from source:
cd C:\Users\matthew.heath\Git\JSharpener
npm install
npm run build
Performs comprehensive analysis including file count, function count, class count, and import/export statistics.
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" analyze [path]
Options:
path: Directory or file to analyze (default: current directory)-o, --output <file>: Save results to JSON file--include <pattern...>: File patterns to include (e.g., "src/**/*.ts")--exclude <pattern...>: File patterns to exclude (e.g., "**/*.test.ts")--config <file>: Path to config file (jsharpener.json)Example:
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" analyze ./src
Output:
JSharpener Analysis Summary
════════════════════════════════════════════════════════════
Files analyzed: 15
Functions: 42
Classes: 8
Imports: 67
Exports: 28
Generates Graphviz DOT format call graphs showing function dependencies.
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" callgraph [path] -o output.dot
Options:
path: Directory or file to analyze-o, --output <file>: Output DOT file (required)--function <name>: Focus on specific function--reverse: Show reverse call graph (what calls this function)--depth <n>: Maximum depth to traverse (default: 10)--module-level: Show module dependencies only--config <file>: Config file pathExamples:
# Full call graph
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" callgraph ./src -o callgraph.dot
# Focus on specific function
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" callgraph ./src --function processData -o callgraph.dot
# Reverse call graph (who calls this)
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" callgraph ./src --function processData --reverse -o callers.dot
# Module-level dependencies
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" callgraph ./src --module-level -o modules.dot
Visualize the graph:
# Convert to SVG
dot -Tsvg callgraph.dot -o callgraph.svg
# Convert to PNG
dot -Tpng callgraph.dot -o callgraph.png
# Open in browser (if GraphvizOnline)
# Upload the .dot file to https://dreampuf.github.io/GraphvizOnline/
Detects unused exports, functions, variables, and imports (dead code detection).
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" treeshake [path]
Options:
path: Directory or file to analyze-o, --output <file>: Save report to file--entry <file...>: Entry point(s) for reachability analysis--format <type>: Output format: json or text (default: text)--config <file>: Config file pathExamples:
# Analyze entire project
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" treeshake ./src
# With entry points
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" treeshake ./src --entry src/index.ts --entry src/cli.ts
# JSON output
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" treeshake ./src --format json -o unused.json
Output:
JSharpener Tree Shaking Report
════════════════════════════════════════════════════════════
Unused Exports (3):
• src/utils/helper.ts:14: unusedFunction
• src/services/old.ts:22: deprecatedMethod
• src/lib/legacy.ts:8: oldHelper
Unused Functions (5):
• src/utils/helper.ts:18: helperFunction
• src/index.ts:7: unusedLocalFunction
• src/services/data.ts:45: processOldFormat
• src/lib/utils.ts:12: debugHelper
• src/lib/utils.ts:89: tempFunction
Unused Variables (2):
• src/config.ts:5: LEGACY_MODE
• src/constants.ts:18: OLD_API_URL
Unused Imports (4):
• src/index.ts:2: import { oldUtil } from './old'
• src/services/api.ts:5: import { deprecated } from './legacy'
• src/utils/format.ts:3: import * as unused from './unused'
• src/lib/helpers.ts:1: import { temp } from './temp'
Potential Savings:
• 87 lines of code could be removed
• Estimated size reduction: 2.14 KB
Analyzes dependencies, finds circular dependencies, and shows external package usage.
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" deps [path]
Options:
path: Directory or file to analyze-o, --output <file>: Save results to file--circular: Only show circular dependencies--external: Analyze external package usage--config <file>: Config file pathExamples:
# Full dependency analysis
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" deps ./src
# Only circular dependencies
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" deps ./src --circular
# External package analysis
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" deps ./src --external
Output:
JSharpener Dependency Analysis
════════════════════════════════════════════════════════════
Circular Dependencies (2):
1. src/circular-a.ts → src/circular-b.ts → src/circular-a.ts
2. src/services/user.ts → src/services/auth.ts → src/services/session.ts → src/services/user.ts
Module Dependencies:
• src/index.ts imports 5 modules
• src/services/api.ts imports 8 modules
• src/utils/helper.ts imports 3 modules
External Dependencies (5):
• typescript: 23 imports
• commander: 4 imports
• fast-glob: 6 imports
• chalk: 12 imports
• ora: 3 imports
Create a jsharpener.json file in your project root:
{
"include": ["src/**/*.ts", "src/**/*.js"],
"exclude": ["**/*.test.ts", "**/*.spec.js", "node_modules/**", "dist/**"],
"entryPoints": ["src/index.ts", "src/cli/index.ts"],
"followDynamicImports": true,
"includeExternalDeps": false,
"detectCircular": true
}
Config Options:
include: Glob patterns for files to includeexclude: Glob patterns for files to excludeentryPoints: Entry points for tree shaking analysisfollowDynamicImports: Track dynamic imports (default: true)includeExternalDeps: Include external packages in analysis (default: false)detectCircular: Detect circular dependencies (default: true)User Request: "Analyze my TypeScript project"
Claude Action:
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" analyze ./src
Interpretation:
User Request: "Find unused code in my project"
Claude Action:
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" treeshake ./src --entry src/index.ts
Interpretation:
User Request: "Show me the call graph for the processData function"
Claude Action:
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" callgraph ./src --function processData -o callgraph.dot
dot -Tsvg callgraph.dot -o callgraph.svg
Interpretation:
--reverse to see who calls processDataUser Request: "Are there any circular dependencies in my code?"
Claude Action:
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" deps ./src --circular
Interpretation:
User Request: "Show me how my modules depend on each other"
Claude Action:
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" callgraph ./src --module-level -o modules.dot
dot -Tsvg modules.dot -o modules.svg
Interpretation:
treeshake --entry src/index.tscallgraph --function main -o main.dotdot -Tsvg main.dot -o main.svgdepsdeps --circularanalyze ./src -o analysis.jsontreeshake ./src -o unused.txtdeps ./src -o deps.txt# Example GitHub Actions workflow
- name: Check for unused code
run: |
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" treeshake ./src --format json -o unused.json
- name: Detect circular dependencies
run: |
node "C:\Users\matthew.heath\Git\JSharpener\dist\cli\index.js" deps ./src --circular
- name: Upload analysis
uses: actions/upload-artifact@v3
with:
name: code-analysis
path: |
unused.json
deps.txt
This is a first version with some known limitations:
import()) are not fully supportedeval() or dynamic code generation is not analyzed--include and --exclude patterns--exclude "**/*.test.ts" "**/*.spec.ts" for faster analysis--module-level for high-level overview instead of full call graph--depth 5 for large projects to limit call graph depth--function to focus on specific function--depth to limit traversal--module-level for high-level view--entry# Install Graphviz for visualization
# Windows: choco install graphviz
# macOS: brew install graphviz
# Linux: apt-get install graphviz
# Convert DOT to various formats
dot -Tsvg callgraph.dot -o callgraph.svg # SVG
dot -Tpng callgraph.dot -o callgraph.png # PNG
dot -Tpdf callgraph.dot -o callgraph.pdf # PDF
// .vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "JSharpener: Analyze",
"type": "shell",
"command": "node",
"args": [
"C:/Users/matthew.heath/Git/JSharpener/dist/cli/index.js",
"analyze",
"${workspaceFolder}/src"
]
},
{
"label": "JSharpener: Find Unused Code",
"type": "shell",
"command": "node",
"args": [
"C:/Users/matthew.heath/Git/JSharpener/dist/cli/index.js",
"treeshake",
"${workspaceFolder}/src"
]
}
]
}
// Potential integration with ESLint
module.exports = {
plugins: ['jsharpener'],
rules: {
'jsharpener/no-circular-deps': 'error',
'jsharpener/no-unused-exports': 'warn'
}
};
# Basic commands
analyze [path] # Project statistics
callgraph [path] -o file.dot # Generate call graph
treeshake [path] # Find unused code
deps [path] # Dependency analysis
# Common options
--include "src/**/*.ts" # Include pattern
--exclude "**/*.test.ts" # Exclude pattern
--config jsharpener.json # Config file
-o output.file # Output file
# Call graph options
--function name # Focus on function
--reverse # Reverse call graph
--depth 5 # Limit depth
--module-level # Module view
# Tree shaking options
--entry src/index.ts # Entry point
--format json # JSON output
# Dependency options
--circular # Only circular deps
--external # External packages