Skip to content

Open source cli tool that is automaticly scanning each file in your project and importing missing imports of Components, functions etc, instead of wasting AI Agents tokens.

License

Notifications You must be signed in to change notification settings

YosefHayim/import-pilot

import-pilot

Stop adding imports by hand. Let the CLI do it.

CI npm License: MIT


The Problem

You write <Card> or formatName() in your code, but the import is missing. Your editor might catch it — or it might not. In large codebases with hundreds of components, this becomes a constant friction point.

import-pilot scans your project, finds every missing import, resolves where it lives, and inserts the correct import statement. It works across frameworks (React, Vue, Angular, Svelte, Astro) and languages (TypeScript, JavaScript, Python), respects your tsconfig.json path aliases, and runs in under a second.


Install

Pick your package manager:

# npm
npm install -g import-pilot

# yarn
yarn global add import-pilot

# pnpm
pnpm add -g import-pilot

# bun
bun add -g import-pilot

Or install locally as a dev dependency:

npm install --save-dev import-pilot

Requires Node.js >= 18


Quick Start

# Fix missing imports in current directory
import-pilot

# Preview what would change (no file modifications)
import-pilot --dry-run

# Scan a specific directory with verbose output
import-pilot ./src --verbose

Interactive Setup

Run the setup wizard to configure import-pilot for your project. It detects your file types, creates a .import-pilot.json config, adds npm scripts, and optionally sets up husky pre-commit hooks — all interactively.

import-pilot init

How It Works

scan files → find used identifiers → check what's imported → resolve the rest → insert imports
  1. Scan — Discovers all files matching your configured extensions
  2. Parse — Extracts existing imports and used identifiers (regex-based, no heavy AST deps)
  3. Resolve — Matches unimported identifiers against an export cache built from your project
  4. Fix — Generates and inserts the correct import statements

Path aliases from tsconfig.json (e.g. @/components/Card) are used automatically when available. Disable with --no-alias.


Supported Languages & Frameworks

Language Extensions Frameworks
TypeScript / JavaScript .ts .tsx .js .jsx React, Angular, Next.js, Nuxt
Vue .vue Vue 2 & 3 (SFC <script> / <script setup>)
Svelte .svelte SvelteKit
Astro .astro Astro frontmatter
Python .py from/import statements, def/class exports
Elixir .ex .exs Mix projects
Go .go Go modules
Rust .rs Cargo projects

See open issues for additional language support.


Reports

After each run, import-pilot can generate a report file at your project root. Configure via .import-pilot.json or the setup wizard.

Format Flag Output file
Markdown --report md import-pilot-report.md
JSON --report json import-pilot-report.json
Text --report txt import-pilot-report.txt
Off --report none (no file)

Reports include: time taken, files scanned, files changed, each import added (before → after), and any unresolved identifiers.


CLI Options

import-pilot [directory] [options]
Option Short Description Default
--dry-run -d Preview changes without writing files false
--verbose -v Detailed output false
--extensions -e File extensions to scan (comma-separated) .ts,.tsx,.js,.jsx,.vue,.svelte,.astro,.py
--ignore -i Glob patterns to ignore (comma-separated)
--config -c Path to config file .import-pilot.json
--no-alias Disable tsconfig path alias resolution false
--report -r Report format: md, json, txt, or none none

Subcommands

Command Description
import-pilot init Interactive setup wizard

Configuration

Create .import-pilot.json in your project root (or run import-pilot init):

{
  "extensions": [".ts", ".tsx", ".vue", ".py"],
  "ignore": ["**/node_modules/**", "**/dist/**", "**/*.test.ts"],
  "useAliases": true,
  "verbose": false,
  "dryRun": false,
  "report": "md"
}

CLI flags override config file values.


Integration

npm scripts

{
  "scripts": {
    "import-pilot": "import-pilot",
    "import-pilot:check": "import-pilot --dry-run --verbose",
    "import-pilot:fix": "import-pilot"
  }
}

Pre-commit hook (husky)

npx husky add .husky/pre-commit "npx import-pilot --dry-run"

Or let import-pilot init set this up for you.

CI

- name: Check imports
  run: npx import-pilot --dry-run --verbose

Contributing

git clone https://github.com/YosefHayim/auto-import-cli.git
cd auto-import-cli
npm install
npm run build
npm test

See open issues for planned features and language support.


License

MIT


About

Open source cli tool that is automaticly scanning each file in your project and importing missing imports of Components, functions etc, instead of wasting AI Agents tokens.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •