Skip to main content
ClaudeWave
Skill85 repo starsupdated 3mo ago

deprecated-api-updater

Identify and replace deprecated API usage in source code with modern alternatives. Use when: (1) Modernizing legacy codebases, (2) Upgrading framework versions (React, Django, Spring, etc.), (3) Fixing deprecation warnings in build output, (4) Preparing for major version upgrades, (5) Ensuring code uses current best practices. Supports Python, JavaScript/TypeScript, Java, and other major languages with both AST-based detection and pattern matching for accurate identification and automated replacement with validation.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE /tmp/deprecated-api-updater && cp -r /tmp/deprecated-api-updater/skills/deprecated-api-updater ~/.claude/skills/deprecated-api-updater
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Deprecated API Updater

Identify and replace deprecated API usage with modern alternatives automatically.

## Quick Start

### Detect Deprecated APIs

Scan code to identify deprecated API usage:

```bash
# Scan a single file
python scripts/detect_deprecated_apis.py src/app.py

# Scan entire directory
python scripts/detect_deprecated_apis.py src/

# Specify language explicitly
python scripts/detect_deprecated_apis.py legacy/ --language python

# Output as JSON
python scripts/detect_deprecated_apis.py src/ --format json
```

### Replace Deprecated APIs

Automatically replace deprecated APIs:

```bash
# Dry run (preview changes)
python scripts/replace_deprecated_apis.py src/ --dry-run

# Apply replacements (creates .bak backups)
python scripts/replace_deprecated_apis.py src/

# Replace in specific language
python scripts/replace_deprecated_apis.py src/ --language javascript
```

## Supported Languages

### Python
- Standard library (collections, time, os, platform, imp)
- Django (URL routing, encoding, translation, models)
- Flask (JSON handling, send_file)
- SQLAlchemy, Pandas, NumPy, Requests

See **[python_deprecations.md](references/python_deprecations.md)** for complete reference.

### JavaScript/TypeScript
- Node.js core (Buffer, url, crypto, fs, util)
- React (lifecycle methods, createClass, PropTypes, Context)
- Express.js (body-parser)
- Webpack, Moment.js alternatives

See **[javascript_deprecations.md](references/javascript_deprecations.md)** for complete reference.

### Java
- Java core (Date/Calendar, Thread methods, finalize)
- Spring Framework (WebMvcConfigurerAdapter, RestTemplate)
- Hibernate (Criteria API)
- JUnit 4 → JUnit 5
- Android (AsyncTask, ProgressDialog, startActivityForResult)

See **[java_deprecations.md](references/java_deprecations.md)** for complete reference.

### Other Languages
- Ruby: URI.escape, Dir.exists?, File.exists?
- Go: ioutil package functions

## Detection Methods

### AST-Based Detection (Precise)

For Python and JavaScript, the skill uses Abstract Syntax Tree parsing for accurate detection:

- **Advantages**: Precise, understands code structure, fewer false positives
- **Limitations**: Requires parseable code, language-specific implementation

**Example**: Detects `os.popen()` by analyzing the AST node structure, not just string matching.

### Pattern Matching (Fast)

For all languages, regex-based pattern matching provides fast detection:

- **Advantages**: Works across all languages, fast, handles unparseable code
- **Limitations**: May have false positives, less precise

**Both methods are used together** for comprehensive detection.

## Workflow

### 1. Scan for Deprecations

Run detection to identify deprecated APIs:

```bash
python scripts/detect_deprecated_apis.py src/
```

**Output example**:
```
Found 3 deprecated API usage(s):

📍 src/utils.py:5:0
   Deprecated: collections.Mapping
   Replacement: collections.abc.Mapping
   Context: from collections import Mapping
   Detection: ast

📍 src/legacy.py:12:9
   Deprecated: os.popen()
   Replacement: subprocess.run() or subprocess.Popen()
   Context: result = os.popen('ls')
   Detection: ast
```

### 2. Review Suggestions

Examine the detected deprecations and suggested replacements. Check the reference documentation for detailed migration guides.

### 3. Test Replacements (Dry Run)

Preview changes before applying:

```bash
python scripts/replace_deprecated_apis.py src/ --dry-run
```

**Output shows**:
- What will be replaced
- Line-by-line changes
- Deprecated API → Replacement API mapping

### 4. Apply Replacements

Apply changes with automatic backups:

```bash
python scripts/replace_deprecated_apis.py src/
```

**Creates**:
- `.bak` backup files for all modified files
- Updated source files with modern APIs

### 5. Validate Changes

**Critical**: Always validate after replacement:

```bash
# Run tests
npm test  # JavaScript
pytest    # Python
mvn test  # Java

# Run linters
eslint src/     # JavaScript
flake8 src/     # Python
mvn checkstyle  # Java

# Manual testing
# Test critical functionality
```

### 6. Commit Changes

Once validated:

```bash
# Review changes
git diff

# Commit
git add .
git commit -m "Replace deprecated APIs with modern alternatives"

# Remove backup files
find . -name "*.bak" -delete
```

## Best Practices

### Before Replacement

1. **Create a branch**: `git checkout -b fix/deprecated-apis`
2. **Commit current state**: Ensure working directory is clean
3. **Run tests**: Verify tests pass before changes
4. **Review deprecation docs**: Check reference files for context

### During Replacement

1. **Start with dry run**: Always preview changes first
2. **Replace incrementally**: Process one module/directory at a time
3. **Keep backups**: Don't delete `.bak` files until validated
4. **Check imports**: Some replacements require new imports

### After Replacement

1. **Run full test suite**: Catch any breaking changes
2. **Check build output**: Look for new warnings
3. **Manual testing**: Test critical user flows
4. **Update dependencies**: Install any newly required packages
5. **Code review**: Have team members review changes

## Common Scenarios

### Scenario 1: Upgrading Django 2.x → 3.x

**Deprecations**:
- `django.conf.urls.url` → `django.urls.path`
- `force_text()` → `force_str()`
- `ugettext` → `gettext`

**Process**:
```bash
# Detect Django-specific deprecations
python scripts/detect_deprecated_apis.py myproject/ --language python

# Preview replacements
python scripts/replace_deprecated_apis.py myproject/ --dry-run

# Apply
python scripts/replace_deprecated_apis.py myproject/

# Test
python manage.py test
```

### Scenario 2: Upgrading React 17 → 18

**Deprecations**:
- `ReactDOM.render()` → `ReactDOM.createRoot()`
- Unsafe lifecycle methods → Modern alternatives

**Process**:
```bash
# Detect React deprecations
python scripts/detect_deprecated_apis.py src/ --language javascript

# Manual review needed for complex cases
# Some React upgrades require s
abstract-domain-explorerSkill

Applies abstract interpretation using different abstract domains (intervals, octagons, polyhedra, sign, congruence) to statically analyze program variables and infer invariants, value ranges, and relationships. Use when analyzing program properties, inferring loop invariants, detecting potential errors, or understanding variable relationships through static analysis.

abstract-invariant-generatorSkill

Uses abstract interpretation to automatically infer loop invariants, function preconditions, and postconditions for formal verification. Generates invariants that capture program behavior and support correctness proofs in Dafny, Isabelle, Coq, and other verification systems. Use when adding formal specifications to code, generating verification conditions, inferring contracts for functions, or discovering loop invariants for proofs.

abstract-state-analyzerSkill

Performs abstract interpretation over source code to infer possible program states, variable ranges, and data properties without executing the program. Reports potential runtime errors including out-of-bounds accesses, null dereferences, type inconsistencies, division by zero, and integer overflows. Use when analyzing code for potential runtime errors, performing static analysis, checking safety properties, or verifying program behavior without execution.

abstract-trace-summarizerSkill

Performs abstract interpretation to produce summarized execution traces and high-level program behavior representations. Highlights key control flow paths, variable relationships, loop invariants, function summaries, and potential runtime states using abstract domains (intervals, signs, nullness, etc.). Use when analyzing program behavior, understanding execution paths, computing loop invariants, tracking variable ranges, detecting potential runtime errors, or generating program summaries without concrete execution.

acsl-annotation-assistantSkill

Create ACSL (ANSI/ISO C Specification Language) formal annotations for C/C++ programs. Use this skill when working with formal verification, adding function contracts (requires/ensures), loop invariants, assertions, memory safety annotations, or any ACSL specifications. Supports Frama-C verification and generates comprehensive formal specifications for C/C++ code.

agent-browserSkill

CLI-based browser automation with persistent page state using ref-based element interaction. Use when users ask to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

ambiguity-detectorSkill

Detects and analyzes ambiguous language in software requirements and user stories. Use when reviewing requirements documents, user stories, specifications, or any software requirement text to identify vague quantifiers, unclear scope, undefined terms, missing edge cases, subjective language, and incomplete specifications. Provides detailed analysis with clarifying questions and suggested improvements.

api-design-assistantSkill

Design and review APIs with suggestions for endpoints, parameters, return types, and best practices. Use when designing new APIs from requirements, reviewing existing API designs, generating API documentation, or getting implementation guidance. Supports REST APIs with focus on endpoint structure, request/response schemas, authentication, pagination, filtering, versioning, and OpenAPI specifications. Triggers when users ask to design, review, document, or improve APIs.