@technicalshree/auto-fix
v1.2.4
Published
Detect, diagnose, and safely fix common local dev environment issues
Maintainers
Readme
auto-fix
auto-fix is a TypeScript CLI that detects local development environment issues and applies safe, explainable fixes for Node, Python, and Docker-based projects.
What it does
- Detects project stack (Node, Python, Docker Compose)
- Diagnoses common local setup problems
- Builds an explicit fix plan before execution
- Runs safe fixes by default
- Supports gated destructive cleanup (
--deep,--approve) - Writes run reports and snapshot metadata for rollback
- Supports best-effort
undofor snapshotted changes - Syncs
.envfiles from.env.exampletemplates (v1.2) - Detects Node/Python runtime version drift (v1.2)
- Auto-configures VS Code Python interpreter path (v1.2)
- Provides actionable guidance for EPERM/EBUSY file lock errors (v1.2)
Requirements
- Node.js 18+
- npm (or compatible Node package manager for development)
- Optional tools (used only when relevant to your project):
- Python +
pip/uv/poetry/pipenv - Docker + Docker Compose
- Python +
Installation
1) Install from npm (recommended)
Run directly without installing globally:
npx auto-fix doctorInstall globally:
npm install -g @technicalshree/auto-fix
auto-fix --help2) Install from source (development)
Clone and install dependencies:
git clone <your-repo-url>
cd ts-cli-tool
npm installBuild the CLI:
npm run buildRun locally:
npm startUse as a CLI command (auto-fix)
After build, the executable is exposed via:
- Bin name:
auto-fix - Entry point:
dist/cli.js
You can run it in either of these ways:
npm start -- doctornode dist/cli.js doctorTo install globally from this repo:
npm run build
npm linkThen use:
auto-fixTo remove global link:
npm unlink -g auto-fixPublish to npm
- Ensure you are logged in to npm:
npm login- Bump the version:
npm version patch- Build and validate the package contents:
npm run build
npm pack --dry-run --cache /tmp/npm-cache-autofix- Publish:
npm publishQuick start
Run safe fixes (default behavior):
auto-fixDiagnosis only (no changes):
auto-fix doctorPreview plan without executing:
auto-fix planShow latest report as JSON:
auto-fix report --jsonRollback latest run (best-effort):
auto-fix undoClear global package manager caches:
auto-fix clear-npm-cache
auto-fix clear-yarn-cache
auto-fix clear-pnpm-cachev1.2 Features
Environment Variable Synchronization
auto-fix detects .env.example files and helps keep your local .env in sync:
- Missing
.env: If.env.exampleexists but.envdoes not, auto-fix will copy it automatically. - Missing keys: If both files exist, auto-fix compares the keys and appends any missing keys from
.env.exampleto your.envwith empty values. - Changes to
.envare snapshotted for undo coverage.
# See env sync in action
auto-fix plan
# Output: ● Copy .env.example to .env
# Output: ● Append 2 missing key(s) to .envRuntime Engine Version Checks
auto-fix validates that your local Node.js and Python versions match what the project expects:
- Node: Reads
.nvmrcor.node-versionand compares the major version againstprocess.version. Emits a warning with suggested action (nvm use). - Python: Reads
.python-versionand flags a version drift warning. - These checks run before dependency installations to catch mismatches early.
- Engine checks fire based on version file existence alone — no
package.jsonorpyproject.tomlrequired.
auto-fix plan
# Output: ● Node version drift detected: expected ~18, running v22.x — Run nvm use
# Output: ● Python version drift: project expects 3.11VS Code Python Integration
When a Python virtual environment (.venv) exists or is being created, auto-fix automatically configures VS Code to use it:
- Sets
python.defaultInterpreterPathin.vscode/settings.json - Prevents false-positive Pylance/Pyright linting errors for new developers
- The change is snapshotted for undo coverage
EPERM/EBUSY Error Guidance
When node_modules cleanup or dependency installation fails due to file locks (common on Windows and macOS), auto-fix now provides specific, actionable error messages:
✖ Permission/lock error (EPERM/EBUSY). Close your IDE, dev servers, or file watchers and retry.This replaces the previous generic "One or more commands failed" message.
Commands
auto-fix [command] [flags]
- Default command (
auto-fix): detect + execute safe fixes doctor: detection and diagnosis only (no modifications)plan: prints execution plan (same as dry-run)report: reads latest report (--runruns fresh first)undo: best-effort restore using latest run snapshotsclear-npm-cache: runsnpm cache clean --forceclear-yarn-cache: runsyarn cache cleanclear-pnpm-cache: runspnpm store prunehelp: show CLI help
Flags (all)
Safety and execution control
--dry-run: show actions, do not execute--deep: enable destructive cleanup steps (for example deletingnode_modules)--approve: skip interactive prompts and allow destructive steps--force-fresh: allow fresh rebuild actions (requires--deepor--approve)--focus <subsystem>: restrict execution to one subsystem- Allowed values:
node,python,docker,all
- Allowed values:
--checks <list>: checks phase selector- Comma-separated values from:
lint,test,format - Example:
--checks lint,test
- Comma-separated values from:
--kill-ports [ports]: enable port cleanup- Optional comma-separated ports
- If omitted, defaults are used from config
Output and reporting
--verbose: print commands and command outputs--quiet: minimal output, still prints final summary--no-color: disable ANSI colors--json: print machine-readable JSON report to stdout--report-path <path>: override report directory path--run: withreport, run a fresh execution instead of reading latest
Typical usage patterns
Safe default run:
auto-fixPlan before execution:
auto-fix planDeep cleanup with explicit approval:
auto-fix --deep --approveOnly Node subsystem:
auto-fix --focus nodeRun only lint + test checks:
auto-fix --checks lint,testKill default configured ports then execute:
auto-fix --kill-portsKill specific ports:
auto-fix --kill-ports 3000,5173,9229Read latest report:
auto-fix report --jsonTrigger run and emit JSON in one command:
auto-fix report --run --jsonClear npm global cache:
auto-fix clear-npm-cacheClear yarn global cache:
auto-fix clear-yarn-cacheClear pnpm global cache:
auto-fix clear-pnpm-cacheConfiguration
auto-fix works without config. To customize behavior, create .autofix.yml in project root.
The loader searches current directory upward until git root.
Example .autofix.yml
version: 1
ports:
default: [3000, 5173, 8000, 8080]
extra: [9229]
node:
package_manager: auto # auto | npm | pnpm | yarn
deep_cleanup:
remove_node_modules: true
remove_lockfile: false
caches:
next: true
vite: true
directories: [".turbo", ".cache"]
python:
venv_path: .venv
install:
prefer: uv # uv | pip | poetry | pipenv | auto
tools:
format: ["ruff format", "black ."]
lint: ["ruff check ."]
test: ["pytest -q"]
docker:
compose_file: auto
safe_down: true
rebuild: true
prune: false
checks:
default: [lint, format, test]
output:
report_dir: .autofix/reports
snapshot_dir: .autofix/snapshots
verbosity: normal # quiet | normal | verboseReports and artifacts
By default:
- Reports:
.autofix/reports/ - Latest report:
.autofix/reports/latest.json - Snapshots:
.autofix/snapshots/
auto-fix also ensures .autofix/ is in .gitignore.
If the configured snapshot directory is not writable, snapshots fall back to a temp directory:
- macOS/Linux pattern:
/tmp/autofix/<run_id>
Undo behavior (important)
auto-fix undo is best-effort and limited to steps that:
- Are marked undoable
- Have snapshot paths recorded in the report
- Still have snapshot files available
Undo cannot restore changes that were never snapshotted or are irreversible by nature.
Exit codes
0: successful run or expected non-error output1: runtime error, missing latest report forreport/undo, ordoctorfound issues
Development
Scripts
npm run dev: run CLI from source withtsx(src/cli.ts)npm run build: compile TypeScript todist/npm start: run built CLI (dist/cli.js)npm test: build silently and run Node test runnernpm run lint: TypeScript type-check only (tsc --noEmit)
Local development workflow
npm install
npm run lint
npm test
npm run dev -- doctor
npm run buildProject structure
src/cli.ts: CLI entrypoint and argument parsingsrc/core/: detection, planning, execution, safety, undosrc/config/: defaults and config loadingsrc/report/: summary and report writingsrc/subsystems/: subsystem-specific checks/fixesenvironment.ts:.envsync logic (v1.2)engines.ts: runtime version checks (v1.2)
src/ui/: terminal renderer and progress hooksdist/: compiled JavaScript outputdocs/: product requirement docs and notestest/: test suitessmoke.test.mjs: CLI smoke testsv1.2.test.mjs: v1.2 feature unit tests
Troubleshooting
auto-fix command not found:
- Run
npm run buildfirst - Use
node dist/cli.js ...directly - If using global link, run
npm linkin project root
No report found for report or undo:
- Run
auto-fixonce first - Check custom
--report-pathusage - Verify
.autofix/reports/latest.jsonexists
Non-interactive environments behave conservatively:
- In polyglot projects (Node + Python + Docker), non-interactive mode without
--approvemay limit execution to a safe subset
Changelog
v1.2.0
- Environment sync: Auto-copy
.env.example→.env; detect and append missing keys - Engine version checks: Validate Node (
.nvmrc) and Python (.python-version) versions before dependency install - VS Code integration: Auto-configure
python.defaultInterpreterPathwhen.venvexists - EPERM handling: Actionable error messages for file lock failures in node steps
- Snapshot improvements: Non-destructive steps with declared snapshot paths are now backed up
- Undo fix: Nested file paths (e.g.,
.vscode/settings.json) are now restored correctly - Test coverage: Added 8 unit tests for v1.2 features
v1.1.x
- Initial release with Node, Python, Docker detection and safe fix execution
- Polyglot project support with interactive confirmation
- Run reports, snapshots, and best-effort undo
- CLI help, version banner, and configurable
.autofix.yml
License
ISC
