home / skills / dexploarer / claudius-skills / import-organizer

This skill automatically organizes and sorts import statements in code files, improving readability and consistency.

npx playbooks add skill dexploarer/claudius-skills --skill import-organizer

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.8 KB
---
name: import-organizer
description: Organizes and sorts import statements in code files. Use when imports are messy or need organization.
allowed-tools: [Read, Edit, Grep]
---

# Import Organizer

Automatically organize and sort import statements in JavaScript, TypeScript, Python, and other languages.

## When to Activate

- "organize imports in this file"
- "sort the imports"
- "clean up import statements"
- "fix import order"

## Process

1. **Read the file** to see current imports
2. **Identify import groups**:
   - External/third-party imports
   - Internal/local imports
   - Type imports (TypeScript)
   - Side-effect imports
3. **Sort within groups** alphabetically
4. **Remove duplicates** if any
5. **Apply language-specific conventions**:
   - JavaScript/TypeScript: External, then internal
   - Python: Standard library, third-party, local
6. **Preserve comments** attached to imports
7. **Update the file** with organized imports

## Language-Specific Rules

### JavaScript/TypeScript
```javascript
// External packages first
import React from 'react'
import { useState } from 'react'
import axios from 'axios'

// Internal imports
import { Button } from './components/Button'
import { utils } from './utils'

// Type imports (TypeScript)
import type { User } from './types'

// Side-effect imports last
import './styles.css'
```

### Python
```python
# Standard library
import os
import sys
from datetime import datetime

# Third-party
import requests
from django.db import models

# Local
from .models import User
from .utils import helper
```

## Best Practices

- Group by source (external vs internal)
- Sort alphabetically within groups
- Separate groups with blank lines
- Remove unused imports (warn user)
- Preserve special comments
- Follow language conventions

Overview

This skill organizes and sorts import statements in code files to produce consistent, readable import sections. It targets JavaScript, TypeScript, Python, and similar languages, grouping imports, removing duplicates, and preserving comments. Use it to clean up messy import blocks or enforce project conventions.

How this skill works

The organizer reads the file to locate import statements and classifies them into groups such as external packages, internal/local modules, type-only imports (TypeScript), and side-effect imports. It sorts imports alphabetically within each group, removes duplicate entries, preserves comments attached to imports, enforces language-specific ordering rules, and writes the updated import block back to the file. It can also warn about unused imports where detection is available.

When to use it

  • When import blocks are unsorted or inconsistent
  • Before commits or pull requests to enforce import style
  • When converting or refactoring files to maintain tidy dependencies
  • To remove duplicate or redundant import lines
  • When you need to apply language-specific import order rules

Best practices

  • Group imports by source (external, internal, types, side-effects) and separate groups with a blank line
  • Sort names alphabetically within each group for predictable diffs
  • Preserve comments attached to imports so developer intent is not lost
  • Warn about unused imports and remove them only after confirmation
  • Follow the target language convention (e.g., Python: stdlib, third-party, local)

Example use cases

  • Organize imports in a TypeScript React component to list external packages first, then local modules, then side-effect CSS imports
  • Clean up Python module imports into standard library, third-party, and local groups before a release
  • Normalize import order across a codebase to reduce merge conflicts and improve readability
  • Remove duplicate imports introduced during large refactors and keep comments intact

FAQ

Which languages are supported?

It supports JavaScript, TypeScript, Python and other languages with recognizable import statements; behavior adapts to language-specific conventions.

Will it remove unused imports automatically?

It can warn about unused imports; automatic removal should be enabled only when confident, because unused detection may depend on complete project context and tooling.