xiaohongshu
xiaohongshu
JavaScript/TypeScript static analysis tool for call graphs, unused code detection (tree shaking), dependency analysis, and circular dependency detection
Full skill instructions
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
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience