DEV Community

Ali Esmaeili
Ali Esmaeili

Posted on • Originally published at aliesm-com.Medium on

Zakaz: Auto-Generate index.ts Files for Cleaner Imports in Your Project

Managing imports and exports in JavaScript/TypeScript projects can quickly become messy — especially as your codebase scales. That’s where Zakaz comes in.

Illustration of Zakaz CLI tool with a clean UI showing an auto-generated index.ts file, designed to simplify JavaScript and TypeScript project structure.

Zakaz is a lightweight CLI tool that automatically creates index.ts or index.js files for each folder in your project, streamlining the way you import and export modules. It helps you avoid repetitive and error-prone manual exports, making your code cleaner and more maintainable.

🔧 What Does Zakaz Do?

Zakaz recursively walks through your project directories, identifies all eligible files (typically .ts, .tsx, .js, or .jsx), and generates corresponding index.ts or index.js files that re-export them. This allows you to simply import a folder instead of specifying each file individually.

✅ Before Zakaz

import Button from './components/ui/Button';
import Input from './components/ui/Input';
Enter fullscreen mode Exit fullscreen mode

✅ After Zakaz

import { Button, Input } from './components';
Enter fullscreen mode Exit fullscreen mode

🚀 Installation

To install Zakaz globally or as a dev dependency:

npm install @navidmnzh/zakaz-cli
Enter fullscreen mode Exit fullscreen mode

To run it instantly using npx:

npx zakaz
Enter fullscreen mode Exit fullscreen mode

🛠️ CLI Options

Zakaz supports several useful flags:


+-------------------------------------------------------------------------+------+
| Description | Flag |
+-------------------------------------------------------------------------+------+
| Base path to start scanning from (default is .) | -b |
| Comma-separated list of directories to ignore (e.g., node_modules,dist) | -d |
| Show detailed logs during the generation process | -l |
+-------------------------------------------------------------------------+------+
Enter fullscreen mode Exit fullscreen mode

Example:

npx zakaz -b . -d node_modules,build -l
Enter fullscreen mode Exit fullscreen mode

📁 Project Structure

Zakaz’s repository is cleanly organized:

  • src/: Contains the core logic (directory walker, export generator)
  • bin/: Command-line entry point
  • tsconfig.json: TypeScript configuration
  • package.json: Metadata and dependencies

💡 Why Use Zakaz?

  • Reduces boilerplate : No more repetitive export statements in every folder.
  • Prevents human error : Automatically manages module exports, reducing mistakes.
  • Improves scalability : Keeps your import paths consistent and clean as the project grows.
  • Cross-compatible : Works with both JavaScript and TypeScript.

🚧 A Few Considerations

  • The tool is actively maintained and may receive additional features in future.
  • Documentation is minimal but the codebase is readable and well-structured.

🧠 Final Thoughts

Zakaz might be small, but its impact is significant — especially for growing codebases. If you’re tired of managing index.ts files manually or want to enforce cleaner architecture in your project, give Zakaz a shot.

You can check out the GitHub repository here:

🙏 Credits

Special thanks to Navid Madannezhad for creating and sharing this useful tool with the developer community. Zakaz is a great example of how small utilities can make a big difference in day-to-day development.

Top comments (0)