Travis Vasceannie 6a164be2e3 fix: switch to file-based locks for inter-process subprocess synchronization
- Replace threading locks with fcntl file-based locks for proper inter-process synchronization
- Hooks run as separate processes, so threading locks don't work across invocations
- Implement non-blocking lock acquisition to prevent hook deadlocks
- Use fcntl.flock on a shared lock file in /tmp/.claude_hooks/subprocess.lock
- Simplify lock usage with context manager pattern in both hooks
- Ensure graceful fallback if lock can't be acquired (e.g., due to concurrent hooks)

This properly fixes the API Error 400 concurrency issues by serializing subprocess
operations across all hook invocations, not just within a single process.
2025-10-21 04:59:02 +00:00
ok
2025-09-28 22:02:45 +00:00

Claude Scripts - Code Quality Analysis Toolkit

A comprehensive Python code quality analysis toolkit for detecting duplicates, complexity metrics, and modernization opportunities.

Features

  • Duplicate Detection: Find similar code patterns across your codebase using advanced similarity algorithms
  • Complexity Analysis: Calculate cyclomatic complexity, maintainability index, and other code metrics
  • Modernization Analysis: Identify opportunities to modernize Python code patterns and syntax
  • Code Smells Detection: Detect common code smells and anti-patterns
  • Multiple Output Formats: Support for JSON, console, and CSV output formats
  • Comprehensive Reports: Full analysis reports with quality scores and recommendations

Installation

pip install claude-scripts

Usage

Command Line Interface

The package provides a claude-quality command with several subcommands:

Duplicate Detection

claude-quality duplicates src/ --threshold 0.8 --format console

Complexity Analysis

claude-quality complexity src/ --threshold 10 --format json

Modernization Analysis

claude-quality modernization src/ --include-type-hints --format console

Full Analysis

claude-quality full-analysis src/ --format json --output report.json

Configuration

Create a configuration file to customize analysis parameters:

claude-quality create-exceptions-template --output-path .quality-exceptions.yaml

Use the configuration file:

claude-quality --config config.yaml --exceptions-file .quality-exceptions.yaml duplicates src/

Command Reference

Global Options

  • --config, -c: Path to configuration file
  • --exceptions-file, -e: Path to exceptions configuration file
  • --verbose, -v: Enable verbose output

Duplicates Command

claude-quality duplicates [OPTIONS] PATHS...

Options:

  • --threshold, -t: Similarity threshold (0.0-1.0, default: 0.8)
  • --min-lines: Minimum lines for duplicate detection (default: 5)
  • --min-tokens: Minimum tokens for duplicate detection (default: 50)
  • --output, -o: Output file for results
  • --format: Output format (json/console/csv, default: json)

Complexity Command

claude-quality complexity [OPTIONS] PATHS...

Options:

  • --threshold: Complexity threshold (default: 10)
  • --output, -o: Output file for results
  • --format: Output format (json/console, default: json)

Modernization Command

claude-quality modernization [OPTIONS] PATHS...

Options:

  • --include-type-hints: Include missing type hint analysis
  • --pydantic-only: Only analyze Pydantic patterns
  • --output, -o: Output file for results
  • --format: Output format (json/console, default: json)

Full Analysis Command

claude-quality full-analysis [OPTIONS] PATHS...

Options:

  • --output, -o: Output file for results
  • --format: Output format (json/console, default: json)

Requirements

  • Python ≥ 3.12
  • Dependencies: click, pyyaml, pydantic, radon

Development

Install development dependencies:

pip install claude-scripts[dev]

License

MIT License - see LICENSE file for details.

Contributing

This is a personal project. Please report issues or suggestions through the repository's issue tracker.

Description
No description provided
Readme MIT 1.4 MiB
Languages
Python 96.1%
Shell 3.3%
Makefile 0.6%