> ## Documentation Index
> Fetch the complete documentation index at: https://docs.depfixer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fix

> Apply fixes from a previous analysis

# Fix Command

The fix command applies fixes from a previous analysis without re-running the analysis.

## Usage

```bash theme={null}
npx depfixer fix [options]
```

## Options

| Option         | Description                          |
| -------------- | ------------------------------------ |
| `--path <dir>` | Project directory (default: current) |

## How It Works

### Session Caching

When you run `npx depfixer` and complete the payment but don't apply fixes, the session is saved:

```
.depfixer/
  session.json    # Stores analysis ID, payment status, file hash
```

### Applying Fixes Later

```bash theme={null}
npx depfixer fix
```

```
Loading session...

Session found:
  Analysis ID: abc123
  Status: PAID
  Analyzed: 2 hours ago

Fetching solution...

🔓 FULL ANALYSIS
──────────────────────────────────────────────────

PACKAGE                            CURRENT       TARGET        TYPE
---------------------------------------------------------------------------
@angular/core                      16.0.0        17.3.0        Major
typescript                         4.9.5         5.4.5         Major

Apply fix to package.json? (Enter/Esc)
```

## Hash Verification

DepFixer verifies your `package.json` hasn't changed since the analysis:

```
⚠ Warning: package.json has been modified since analysis

The fixes were calculated for a different version of your package.json.
Applying them may cause unexpected results.

Continue anyway? (Enter/Esc)
```

## Session File Structure

The session is stored in `.depfixer/session.json`:

```json theme={null}
{
  "analysisId": "abc123-def456",
  "intent": "ANALYZE",
  "originalFileHash": "sha256:...",
  "cost": 15,
  "tierName": "Small",
  "status": "PAID",
  "timestamp": "2024-01-15T10:30:00Z"
}
```

## Use Cases

### Deferred Fixes

1. Run analysis during work hours
2. Review changes with team
3. Apply fixes during maintenance window

```bash theme={null}
# Morning: Analyze
npx depfixer
# Pay but select "No" when asked to apply

# Evening: Apply
npx depfixer fix
```

## Backup

When fixes are applied, DepFixer creates a backup:

```
package.json.bak    # Original package.json before fixes
```

To restore:

```bash theme={null}
# Windows
copy package.json.bak package.json

# macOS/Linux
cp package.json.bak package.json
```

## Error Handling

### No Session Found

```
Error: No session found

Run `npx depfixer` first to analyze your project.
```

### Unpaid Session

```
Error: Analysis not paid

The previous analysis was not completed.
Run `npx depfixer` to continue.
```
