Agent skill
import-formatter
Format and organize import statements in code files. Use when imports are messy, unordered, or need to follow project conventions. Automatically groups imports by type (standard library, third-party, local) and sorts them alphabetically.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/import-formatter
SKILL.md
Import Formatter Skill
Instructions
- Identify all import statements in the file
- Group imports into three categories:
- Standard library imports (Python stdlib, Node.js built-ins, etc.)
- Third-party imports (from npm, pip, etc.)
- Local/project imports (relative or absolute project paths)
- Sort each group alphabetically
- Add blank lines between groups (standard library, third-party, local)
- Remove duplicate imports
- Consolidate imports from the same module when possible
- Preserve import aliases and type-only imports
- Follow language-specific conventions (e.g., Python PEP 8, JavaScript ES6 modules)
Examples
Input (Python):
from typing import List, Dict
import os
from myapp.models import User
import requests
from typing import Optional
from myapp.utils import helper
Output:
import os
from typing import Dict, List, Optional
import requests
from myapp.models import User
from myapp.utils import helper
Input (JavaScript/TypeScript):
import { useState } from 'react'
import './styles.css'
import axios from 'axios'
import { Component } from './Component'
import { useEffect } from 'react'
Output:
import { useEffect, useState } from 'react'
import axios from 'axios'
import { Component } from './Component'
import './styles.css'
Language-Specific Rules
Python:
- Standard library first
- Third-party packages second
- Local imports last
- Use absolute imports when possible
- Group by package, then alphabetically
JavaScript/TypeScript:
- External packages first (node_modules)
- Internal modules second
- Relative imports last
- Side-effect imports (CSS, etc.) at the end
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?