### Contribute to clrd project setup Source: https://github.com/relkimm/clrd/blob/main/README.md Commands to clone the clrd repository, install dependencies, run tests, and execute the tool locally. This is useful for developers looking to contribute to the project. ```bash # Clone the repo git clone https://github.com/relkimm/clrd.git cd clrd # Install dependencies cargo build # Run tests cargo test # Run locally cargo run -- scan --format pretty ``` -------------------------------- ### Install clrd via npm (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Installs the clrd command-line tool globally using npm. This allows you to run clrd commands from any directory on your system. Alternatively, you can use `npx clrd scan` without a global installation. ```bash npm install -g clrd ``` -------------------------------- ### Custom Configuration via CLI (Bash) Source: https://context7.com/relkimm/clrd/llms.txt Provides examples of how to customize clrd's behavior using command-line arguments, such as specifying file extensions, adding ignore patterns, including test files, setting confidence, changing the working directory, and enabling verbose logging. ```bash # Custom file extensions clrd scan --extensions ts,tsx,vue # Additional ignore patterns clrd scan --ignore "vendor/**,third_party/**,generated/**" # Include test files clrd scan --include-tests # Higher confidence threshold clrd scan --confidence 0.9 # Working directory clrd -C /path/to/project scan # Verbose logging clrd -v scan ``` -------------------------------- ### Example Commit Messages (Text) Source: https://github.com/relkimm/clrd/blob/main/CONTRIBUTING.md Examples of well-formatted commit messages for the clrd project, adhering to guidelines like present tense and imperative mood. ```text Add confidence threshold flag to scan command Fix false positive detection for barrel files Improve parallel file walking performance ``` -------------------------------- ### Install clrd via Cargo (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Installs the clrd command-line tool using Cargo, Rust's package manager. This method is suitable for users who have Rust and Cargo installed and prefer managing dependencies through Cargo. ```bash cargo install clrd ``` -------------------------------- ### Programmatic API usage in Rust Source: https://github.com/relkimm/clrd/blob/main/README.md Example demonstrating how to use the clrd programmatic API in Rust to scan for dead code. It shows initializing a `Scanner` with custom extensions and confidence thresholds, and then performing the scan. ```rust use clrd::Scanner; #[tokio::main] async fn main() -> anyhow::Result<()> { let scanner = Scanner::new("./src") .with_extensions(vec!["ts".into(), "tsx".into()]) .with_confidence_threshold(0.8); let result = scanner.scan().await?; println!("Found {} issues", result.dead_code.len()); Ok(()) } ``` -------------------------------- ### Configure clrd scan extensions Source: https://github.com/relkimm/clrd/blob/main/README.md Example of how to configure the `clrd scan` command to process specific file extensions. By default, clrd supports `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, and `.cjs`. ```bash # Scan only TypeScript clrd scan --extensions ts,tsx ``` -------------------------------- ### Configure clrd ignore patterns Source: https://github.com/relkimm/clrd/blob/main/README.md Example of how to configure custom ignore patterns for the `clrd scan` command. This allows users to exclude specific files or directories from the analysis. Default ignores include `node_modules`, `dist`, `build`, and `.git`. ```bash # Add custom ignores clrd scan --ignore "**/*.test.ts,**/*.spec.ts,**/fixtures/**" ``` -------------------------------- ### DeadCodeKind Enumeration (JSON) Source: https://context7.com/relkimm/clrd/llms.txt Lists the different categories of dead code that clrd can detect. Includes an example of how a 'kind' might be used with its description and typical confidence score. ```json { "kinds": [ "unused_export", "unreachable_function", "unused_variable", "unused_import", "zombie_file", "unused_type", "unused_class", "unused_enum", "dead_branch" ], "example_usage": { "kind": "unused_export", "description": "Exported symbol with no external references", "typical_confidence": 0.85 } } ``` -------------------------------- ### Rust Library API: Process Scan Results with Type Safety Source: https://context7.com/relkimm/clrd/llms.txt Process CLRD scan results in Rust, leveraging strong typing for structured access to dead code information. This example demonstrates filtering results by kind (e.g., UnusedExport, ZombieFile) and accessing detailed context information. ```rust use clrd::{Scanner, DeadCodeKind, ScanOutput}; #[tokio::main] async fn main() -> anyhow::Result<()> { let scanner = Scanner::new("./project") .with_extensions(vec!["js".into(), "jsx".into()]) .with_confidence_threshold(0.5); let result: ScanOutput = scanner.scan().await?; // Group by kind let unused_exports = result.dead_code.iter() .filter(|item| matches!(item.kind, DeadCodeKind::UnusedExport)) .collect::>(); let zombie_files = result.dead_code.iter() .filter(|item| matches!(item.kind, DeadCodeKind::ZombieFile)) .collect::>(); println!("Unused Exports: {}", unused_exports.len()); for item in unused_exports { println!(" - {} in {}", item.name, item.relative_path); } println!("\nZombie Files: {}", zombie_files.len()); for item in zombie_files { println!(" - {}", item.relative_path); } // Access detailed context for item in &result.dead_code { if let Some(context) = &item.context { if context.possibly_dynamic { println!("⚠️ {} might be dynamically imported", item.name); } if context.public_api { println!("📦 {} is part of public API", item.name); } if !context.partial_references.is_empty() { println!("🔗 {} has partial refs: {{:?}}", item.name, context.partial_references ); } } } Ok(()) } ``` -------------------------------- ### Running CLRD Locally Source: https://github.com/relkimm/clrd/blob/main/claude.md Demonstrates how to execute the CLRD tool locally, both via Cargo for direct Rust execution and via npm after a successful build for Node.js environment execution. ```bash # Via Cargo cargo run -- scan --format pretty # Via npm (after build) node bin/clrd.js scan --format pretty ``` -------------------------------- ### Rust Project Build Commands Source: https://github.com/relkimm/clrd/blob/main/claude.md Standard Cargo commands for building and testing Rust projects. Includes commands for development builds, optimized release builds, running all tests, and building for npm distribution using napi-rs. ```bash # Development build cargo build # Release build (optimized) cargo build --release # Run tests cargo test # Build for npm (via napi-rs) npm run build # Debug build for npm npm run build:debug ``` -------------------------------- ### clrd init Command Source: https://github.com/relkimm/clrd/blob/main/README.md Initializes clrd by generating AI context files for tools like Claude and Cursor. ```APIDOC ## `clrd init` ### Description Initializes clrd by generating AI context files to help AI agents understand your codebase. ### Method CLI Command ### Endpoint `clrd init` ### Parameters This command does not accept any parameters. ### Request Example ```bash clrd init ``` ### Response #### Success Response (200) - **Output**: Creates files like `claude.md`, `agent.md`, and `.cursorrules` in the current directory. #### Response Example (No direct output, but files are generated in the filesystem) ``` -------------------------------- ### CLRD CLI Commands Source: https://github.com/relkimm/clrd/blob/main/claude.md Provides essential commands for interacting with the CLRD tool. These commands cover project initialization, dead code scanning with various formatting and filtering options, updating AI context files, fixing identified dead code with different modes, and generating JSON schemas for LLM integration. ```bash # Initialize project with AI context files clrd init [--force] # Scan for dead code clrd scan [--format pretty|json|compact|tui] \ [--extensions ts,tsx,js] \ [--ignore "**/*.test.ts"] \ [--confidence 0.5] \ [--include-tests] \ [--output report.json] # Update AI context files with scan results clrd map [--confidence 0.5] # Fix dead code clrd fix [--dry-run] # Preview only (default) [--soft] # Comment out instead of delete [--force] # Hard delete (requires clean git) [--confidence 0.8] # Output JSON schema for LLM integration clrd schema ``` -------------------------------- ### Build and Test CLI Project (Bash) Source: https://github.com/relkimm/clrd/blob/main/CONTRIBUTING.md Steps to clone, build, test, and run the clrd CLI project using Cargo and npm. Assumes Rust and Node.js prerequisites are met. ```bash git clone https://github.com/YOUR_USERNAME/clrd.git cd clrd # Build the project cargo build # Run tests cargo test # Run the CLI cargo run -- scan --format pretty ``` ```bash # Install Node dependencies npm install # Build native module npm run build # Test npm package node bin/clrd.js scan ``` -------------------------------- ### clrd CLI Help (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Displays the main help message for the clrd command-line tool, outlining its purpose, usage, and available commands. ```bash clrd --help ``` -------------------------------- ### Default Configuration (Rust) Source: https://context7.com/relkimm/clrd/llms.txt Illustrates the default configuration settings for clrd, including file extensions to scan, default ignore patterns (respecting .gitignore), confidence threshold, and whether test files are included. ```rust // Extensions scanned by default let extensions = vec!["ts", "tsx", "js", "jsx", "mjs", "cjs"]; // Default ignore patterns (respects .gitignore) let ignore_patterns = vec![ "**/node_modules/**", "**/dist/**", "**/build/**", "**/.git/**", "**/coverage/**", "**/*.min.js", "**/*.bundle.js" ]; // Default confidence threshold let confidence_threshold = 0.5; // Test files excluded by default let include_tests = false; ``` -------------------------------- ### Initialize clrd AI context files (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Generates AI context files (`claude.md`, `agent.md`, `.cursorrules`) to help AI tools understand your codebase. These files are essential for integrating clrd with AI assistants like Claude or Cursor. ```bash clrd init ``` -------------------------------- ### Run Tests and Specific Tests (Bash) Source: https://github.com/relkimm/clrd/blob/main/CONTRIBUTING.md Commands to execute the test suite for the clrd project. Includes options for running all tests, specific tests, and capturing output. ```bash # Run all tests cargo test # Run specific test cargo test test_scanner_creation # Run with output cargo test -- --nocapture ``` -------------------------------- ### clrd map command options (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Displays the help message for the `clrd map` command, explaining its options such as running a fresh scan before mapping and setting the confidence threshold. ```bash clrd map --help ``` -------------------------------- ### Initialize AI Context Files with clrd CLI Source: https://context7.com/relkimm/clrd/llms.txt Generates context files (e.g., claude.md, agent.md, .cursorrules) for AI coding assistants. Supports a force option to overwrite existing files. ```bash clrd init clrd init --force ``` -------------------------------- ### clrd scan command options (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Shows the help message specifically for the `clrd scan` command, detailing its various options for controlling output format, file extensions, ignored patterns, and confidence thresholds. ```bash clrd scan --help ``` -------------------------------- ### Build clrd from source (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Clones the clrd repository from GitHub and builds the release version using Cargo. This is useful for developers who want to contribute to clrd, use the latest unreleased features, or build a custom version. ```bash git clone https://github.com/relkimm/clrd.git cd clrd cargo build --release ``` -------------------------------- ### clrd CLI Reference Source: https://github.com/relkimm/clrd/blob/main/README.md This section details the available commands and options for the clrd command-line interface, allowing users to perform various code maintenance tasks. ```APIDOC ## clrd CLI Reference clrd - AI-native code maintenance tool USAGE: clrd COMMANDS: init Initialize clrd with AI context files scan Scan for dead code map Update AI context files with scan results fix Remove or comment out dead code schema Output JSON schema for LLM integration OPTIONS: -v, --verbose Enable verbose output -C, --directory Working directory -h, --help Print help -V, --version Print version ``` -------------------------------- ### Scan and output JSON to a file (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Scans for dead code, formats the output as JSON, and saves it to a specified file (`dead-code.json`). This is useful for storing analysis results or sharing them. ```bash clrd scan --format json --output dead-code.json ``` -------------------------------- ### clrd schema Command Source: https://github.com/relkimm/clrd/blob/main/README.md Outputs the JSON schema used for AI integration, facilitating LLM tool use. ```APIDOC ## `clrd schema` ### Description Outputs the JSON schema that `clrd scan --format json` adheres to. This is useful for configuring AI agents to use clrd as a tool. ### Method CLI Command ### Endpoint `clrd schema` ### Parameters This command does not accept any parameters. ### Request Example ```bash clrd schema ``` ### Response #### Success Response (200) - **Output**: A JSON string representing the schema for the dead code report. #### Response Example ```json { "type": "object", "properties": { "issues": { "type": "array", "items": { "type": "object", "properties": { "file": {"type": "string"}, "name": {"type": "string"}, "type": {"type": "string"}, "references": {"type": "integer"}, "confidence": {"type": "number"} }, "required": ["file", "name", "type", "references", "confidence"] } }, "summary": { "type": "object", "properties": { "files_analyzed": {"type": "integer"}, "issues_found": {"type": "integer"}, "time_ms": {"type": "integer"} }, "required": ["files_analyzed", "issues_found", "time_ms"] } }, "required": ["issues", "summary"] } ``` ``` -------------------------------- ### Run clrd dead code scan (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md This command initiates a dead code scan using the clrd tool. It provides a summary of found issues, including the file, specific dead code element, and a confidence score. The output is human-readable by default. ```bash clrd scan ``` -------------------------------- ### Update AI context files with dead code results (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Updates the AI context files with the latest dead code analysis results. This ensures that AI agents have up-to-date information about potential code improvements. ```bash clrd map ``` -------------------------------- ### clrd map Command Source: https://github.com/relkimm/clrd/blob/main/README.md Updates AI context files with the latest dead code scan results. ```APIDOC ## `clrd map` ### Description Updates AI context files with the latest dead code scan results, ensuring AI agents have up-to-date information. ### Method CLI Command ### Endpoint `clrd map` ### Options #### Query Parameters - **--scan** (boolean) - Run a fresh scan before mapping. - **--confidence** (float) - Minimum confidence threshold for reporting dead code during the scan phase. Default: `0.5`. ### Request Example ```bash clrd map --scan ``` ### Response #### Success Response (200) - **Output**: Updates the AI context files (`claude.md`, `agent.md`, `.cursorrules`) with the latest dead code information. #### Response Example (No direct output, but files are updated in the filesystem) ``` -------------------------------- ### Generate JSON Schema for LLM Integration with clrd CLI Source: https://context7.com/relkimm/clrd/llms.txt Outputs JSON schema definitions for integrating clrd with AI agents and LLM tools, enabling machine-readable analysis results. ```bash clrd schema ``` -------------------------------- ### Preview dead code fixes (dry run) (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Simulates the `clrd fix` command without making any actual changes to the codebase. This allows you to review the proposed modifications before applying them. ```bash clrd fix --dry-run ``` -------------------------------- ### Rust Library API: Scanner Builder Pattern Source: https://context7.com/relkimm/clrd/llms.txt Configure and build a CLRD scanner instance using a builder pattern in Rust. This allows for fine-grained control over scan parameters such as file extensions, ignore patterns, and confidence thresholds. ```rust use clrd::Scanner; #[tokio::main] async fn main() -> anyhow::Result<()> { // Create scanner with builder pattern let scanner = Scanner::new("./src") .with_extensions(vec!["ts".into(), "tsx".into()]) .with_ignore_patterns(vec![ "**/node_modules/**".into(), "**/dist/**".into(), ]) .include_tests(false) .with_confidence_threshold(0.7); // Execute scan let result = scanner.scan().await?; println!("Scan Summary:"); println!(" Files scanned: {}", result.total_files_scanned); println!(" Duration: {}ms", result.scan_duration_ms); println!(" Total issues: {}", result.summary.total_issues); println!(" High confidence: {}", result.summary.high_confidence_issues); // Process results for item in &result.dead_code { if item.confidence >= 0.8 { println!("\n{} - {} (confidence: {{:.2}})", item.kind, item.name, item.confidence ); println!(" File: {}", item.relative_path); println!(" Line: {}", item.span.start); println!(" Reason: {}", item.reason); } } // Export to JSON for LLM processing let json = serde_json::to_string_pretty(&result)?; std::fs::write("dead-code-report.json", json)?; Ok(()) } ``` -------------------------------- ### clrd scan Command Source: https://github.com/relkimm/clrd/blob/main/README.md The `scan` command analyzes the codebase to detect dead code, providing various output formats and filtering options. ```APIDOC ## `clrd scan` ### Description Scan for dead code in the project. ### Method CLI Command ### Endpoint `clrd scan` ### Options #### Query Parameters - **-f, --format** (string) - Output format. Values: `pretty`, `json`, `compact`, `tui`. Default: `pretty`. - **-e, --extensions** (string) - File extensions to analyze (comma-separated). - **-i, --ignore** (string) - Patterns to ignore (comma-separated globs). - **--include-tests** (boolean) - Include test files in the analysis. - **--confidence** (float) - Minimum confidence threshold for reporting dead code. Default: `0.5`. - **-o, --output** (string) - Output file path (used with `json` format). ### Request Example ```bash clrd scan --format json --confidence 0.8 --output dead_code_report.json ``` ### Response #### Success Response (200) - **Output**: Depends on the `--format` option. Can be pretty-printed text, JSON, compact text, or a TUI. #### Response Example (JSON format) ```json { "issues": [ { "file": "src/utils/legacy.ts", "name": "unusedHelper", "type": "unused_export", "references": 0, "confidence": 0.95 }, { "file": "src/components/Button.tsx", "name": "OldButtonProps", "type": "unused_type", "references": 0, "confidence": 0.92 } ], "summary": { "files_analyzed": 1847, "issues_found": 23, "time_ms": 142 } } ``` ``` -------------------------------- ### LLM Judgment Request JSON Format Source: https://github.com/relkimm/clrd/blob/main/claude.md Defines the JSON structure for sending dead code analysis results to an LLM for judgment. It includes details about the identified dead code items, their file paths, names, kinds, confidence scores, code snippets, and reasons, along with project context. ```json { "items": [ { "file_path": "src/utils/helper.ts", "name": "unusedFunction", "kind": "unused_export", "confidence": 0.75, "code_snippet": "export function unusedFunction() {...}", "reason": "0 references found" } ], "project_context": { "name": "my-project", "framework": "react" } } ``` -------------------------------- ### Scan for Dead Code with clrd CLI Source: https://context7.com/relkimm/clrd/llms.txt Scans a codebase for dead code (unused exports, imports, functions, types, files). Supports various output formats (pretty, JSON, TUI, compact), confidence filtering, file type/test inclusion, and custom ignore patterns. ```bash clrd scan clrd scan --format json --output dead-code.json clrd scan --confidence 0.8 clrd scan --extensions ts,tsx clrd scan --include-tests clrd scan --format tui clrd scan --format compact clrd scan --ignore "**/*.test.ts,**/*.spec.ts,**/fixtures/**" ``` -------------------------------- ### clrd fix command options Source: https://github.com/relkimm/clrd/blob/main/README.md Options for the `clrd fix` command, used to preview or apply changes for dead code elimination. It includes flags for dry runs, soft deletion, forcing changes, confidence thresholds, and specifying files. ```bash OPTIONS: --dry-run Preview changes without modifying files --soft Comment out code instead of deleting --force Force removal (requires clean git status) --confidence Only fix items above threshold [default: 0.8] -f, --files Specific files to fix ``` -------------------------------- ### Scan for dead code with JSON output (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Executes a dead code scan and outputs the results in JSON format. This is ideal for programmatic consumption, such as feeding the data to AI models or other scripting processes. ```bash clrd scan --format json ``` -------------------------------- ### clrd fix Command Source: https://github.com/relkimm/clrd/blob/main/README.md Removes or comments out detected dead code based on the analysis. ```APIDOC ## `clrd fix` ### Description Applies changes to fix detected dead code by either removing or commenting it out. ### Method CLI Command ### Endpoint `clrd fix` ### Options #### Query Parameters - **--dry-run** (boolean) - Preview the changes without applying them. - **--soft** (boolean) - Comment out the dead code instead of deleting it. - **--force** (boolean) - Force removal of dead code. Requires a clean git working directory. ### Request Example ```bash clrd fix --soft clrd fix --force ``` ### Response #### Success Response (200) - **Output**: Modifies files in the project to address dead code. Use `--dry-run` to preview. #### Response Example (Files are modified in the project) ``` -------------------------------- ### ScanOutput Schema (JSON) Source: https://context7.com/relkimm/clrd/llms.txt Defines the structure of the JSON output produced by the clrd tool. This schema details detected dead code, scan metadata, and a summary of issues found, suitable for programmatic consumption. ```json { "version": "0.1.10", "root": "/path/to/project", "timestamp": "1701878400", "dead_code": [ { "file_path": "/path/to/project/src/utils/legacy.ts", "relative_path": "src/utils/legacy.ts", "span": { "start": 15, "end": 23, "col_start": 0, "col_end": 1 }, "code_snippet": "export function unusedHelper() {\n return 'deprecated';\n}", "kind": "unused_export", "name": "unusedHelper", "reason": "0 references found across the codebase", "confidence": 0.95, "context": { "possibly_dynamic": false, "in_test_file": false, "public_api": false, "partial_references": [], "doc_comment": null } }, { "file_path": "/path/to/project/src/old-feature.ts", "relative_path": "src/old-feature.ts", "span": { "start": 1, "end": 50, "col_start": 0, "col_end": 0 }, "code_snippet": "// entire file content", "kind": "zombie_file", "name": "old-feature.ts", "reason": "File is never imported by other modules", "confidence": 0.88, "context": { "possibly_dynamic": true, "in_test_file": false, "public_api": false, "partial_references": [], "doc_comment": null } } ], "total_files_scanned": 1847, "total_lines": 85420, "scan_duration_ms": 142, "summary": { "unused_exports": 15, "unreachable_functions": 3, "unused_variables": 2, "unused_imports": 8, "zombie_files": 2, "unused_types": 5, "total_issues": 35, "high_confidence_issues": 23, "low_confidence_issues": 12 } } ``` -------------------------------- ### Scan for dead code with interactive TUI (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Performs a dead code scan and presents the results in a Text User Interface (TUI). This offers an interactive way to explore the detected issues directly in the terminal. ```bash clrd scan --format tui ``` -------------------------------- ### Programmatic Dead Code Scan in Node.js Source: https://context7.com/relkimm/clrd/llms.txt Executes dead code analysis programmatically from Node.js applications using the 'clrd' library. Allows configuration of root directory, file extensions, ignore patterns, and test file inclusion, returning detailed scan results. ```javascript const { scan } = require('clrd'); async function analyzeProject() { try { const result = await scan({ root: './src', extensions: ['ts', 'tsx', 'js', 'jsx'], ignorePatterns: [ '**/node_modules/**', '**/dist/**', '**/*.test.ts' ], includeTests: false }); console.log(`Scanned ${result.totalFilesScanned} files in ${result.scanDurationMs}ms`); console.log(`Found ${result.items.length} dead code items`); const critical = result.items.filter(item => item.confidence >= 0.8); critical.forEach(item => { console.log(`${item.kind}: ${item.name} in ${item.filePath}:${item.lineStart}`); console.log(` Confidence: ${(item.confidence * 100).toFixed(0)}%`); console.log(` Reason: ${item.reason}`); }); return result; } catch (error) { console.error('Scan failed:', error.message); throw error; } } analyzeProject(); ``` -------------------------------- ### LLM Judgment Response JSON Format Source: https://github.com/relkimm/clrd/blob/main/claude.md Specifies the JSON structure for the LLM's response regarding dead code analysis. It categorizes findings into 'confirmed' actions (like 'delete') and 'rejected' items with reasons, allowing for automated or reviewed code modifications. ```json { "confirmed": [ { "file_path": "src/utils/helper.ts", "name": "unusedFunction", "action": "delete" } ], "rejected": [ { "file_path": "...", "name": "...", "reason": "Used via dynamic import" } ] } ``` -------------------------------- ### Scan for dead code with confidence filtering (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Runs a dead code scan and filters the results to include only issues with a confidence score of 0.8 or higher. This helps focus on high-certainty dead code. ```bash clrd scan --confidence 0.8 ``` -------------------------------- ### Update AI Context with Scan Results using clrd CLI Source: https://context7.com/relkimm/clrd/llms.txt Runs a dead code scan and updates AI context files. Can use previous scan results or perform a fresh scan, with options to filter by confidence. ```bash clrd map clrd map --scan clrd map --confidence 0.8 ``` -------------------------------- ### Comment out dead code instead of deleting (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Uses the `clrd fix` command to comment out detected dead code instead of removing it. This is a safer approach, allowing for easier restoration if needed. ```bash clrd fix --soft ``` -------------------------------- ### Run CLRD CLI from Node.js Source: https://context7.com/relkimm/clrd/llms.txt Execute CLRD CLI commands programmatically from a Node.js environment. This function handles command execution, output parsing, and error management, returning the exit code. ```javascript const { run } = require('clrd'); async function executeCli() { try { // Run scan command with JSON output const exitCode = await run([ 'scan', '--format', 'json', '--confidence', '0.7', '--output', 'scan-results.json' ]); if (exitCode === 0) { console.log('No high-confidence dead code found'); } else { console.log('Dead code detected, check scan-results.json'); } return exitCode; } catch (error) { console.error('CLI execution failed:', error.message); return 1; } } // Run init command async function initializeProject() { await run(['init', '--force']); console.log('AI context files created'); } // Run fix with dry-run async function previewFixes() { await run(['fix', '--dry-run', '--confidence', '0.8']); } executeCli(); ``` -------------------------------- ### Fix Dead Code Issues with clrd CLI Source: https://context7.com/relkimm/clrd/llms.txt Removes or comments out detected dead code with safety checks. Supports dry runs, soft commenting, forced removal (requires clean git), file-specific fixes, and confidence threshold adjustments. ```bash clrd fix --dry-run clrd fix --soft clrd fix --force --confidence 0.8 clrd fix --files src/utils/legacy.ts,src/old-api.ts clrd fix --dry-run --confidence 0.5 ``` -------------------------------- ### Forcefully remove dead code (Bash) Source: https://github.com/relkimm/clrd/blob/main/README.md Executes the `clrd fix` command to remove dead code. This option requires a clean git working directory and should be used with caution. ```bash clrd fix --force ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.