Component Generator
Atomic Bomb

Create Atomic Design-based Atoms, Molecules, Organisms, Templates, and Pages with matching stories, tests, styles, mocks, interfaces, and barrel exports.

Generate Components
View on GitHub
Atomic Bomb preview
Atomic Bomb

Atomic Bomb

Atomic Bomb is a powerful component generator that creates Atomic Design-based Atoms, Molecules, Organisms, Templates, and Pages with matching stories, tests, styles, mocks, interfaces, and barrel exports. It streamlines the development process by automating the creation of well-structured and maintainable components.

number-1

Generate Components

Use Atomic Bomb's CLI to generate components based on the Atomic Design methodology, ensuring a consistent and scalable architecture for your React and React Native projects.

Shell
npx atomic-bomb --type atom --name Logo,Button,Paragraph
px atomic-bomb --type molecule --name "Button Bar"
npx atomic-bomb --type organism --name Header
npx atomic-bomb --type template --name HomePage
npx atomic-bomb --type page --name AboutPage

Replacewith the desired Atomic Design level (atom, molecule, organism, template, page) andwith the name of your component.

number-2

Create Stories and Tests

Automatically generate Storybook stories and test files for each component, enabling you to develop and test your components in isolation.

number-3

Maintain Consistent Styles and Mocks

Atomic Bomb creates matching style files and mock data for your components, helping you maintain a consistent design system across your application.

number-4

Experimental AI Features (v7.0.x)

In this version, Atomic Bomb introduces experimental AI features that leverage natural language processing to enhance the component generation process. These features include the ability to generate components based on descriptive prompts, automatically suggest improvements to existing components, and provide insights into potential design inconsistencies. While these AI capabilities are still in the early stages of development, they represent a significant step towards making Atomic Bomb an even more powerful tool for developers looking to create scalable and maintainable component libraries.

Shell
atomic-bomb --type molecule --name "Button Group" --ai --prompt "Use primary and secondary actions with optional icons."

Warning: The AI features in Atomic Bomb v7.0.x are experimental and may produce inconsistent results. Use them with caution and always review the generated code for accuracy and maintainability.

Features

Generate Atomic Design-based Atoms, Molecules, Organisms, Templates, and Pages with matching stories, tests, styles, mocks, interfaces, and barrel exports.

    AI Enabled

    The new experimental AI features in Atomic Bomb v7.0.x leverage natural language processing to enhance the component generation process, allowing developers to create components based on descriptive prompts.

      Atomic Bomb

      Atomic Bomb is a small CLI for generating React project structure from atomic design and DDD-style conventions.

      It can create:

      • atomic components:
        atom
        ,
        molecule
        ,
        organism
        ,
        template
        ,
        page
      • shared files next to components:
        hook
        ,
        lib
      • domain containers and subdomain folders
      • scoped domain files:
        api
        ,
        event
        ,
        helper
        ,
        hook
        ,
        model
        ,
        page
        ,
        service
        ,
        state
      • structure JSON exports and imports
      • recursive generated item removal

      > **Important** > This tool is for educational purposes.

      Install

      Shell
      npm install --global atomic-bomb

      Or install it in a project:

      Shell
      npm install --save-dev atomic-bomb
      yarn add -D atomic-bomb

      You can also run it with

      npx
      :

      Shell
      npx atomic-bomb@latest --type atom --name Logo

      Requirements

      Run Atomic Bomb from the root of a project with a

      package.json
      .

      The CLI checks the configured

      search
      package in your project dependencies. For React templates this is usually
      react
      .

      Quick Start

      Configure the platform:

      Shell
      atomic-bomb --platform react-ts
      atomic-bomb -p react-ts

      Create a component:

      Shell
      atomic-bomb --type atom --name Logo

      After the first configuration,

      --platform
      can be omitted. Atomic Bomb reads it from
      .atomic-bomb
      .

      Shell
      atomic-bomb --type molecule --name "Button Group"

      Usage

      Shell
      atomic-bomb --platform [PLATFORM]
      atomic-bomb -p [PLATFORM]

      atomic-bomb --type atom|molecule|organism|template|page --name [NAME](,[NAME],[NAME])

      atomic-bomb --type hook --name [NAME](,[NAME],[NAME])
      atomic-bomb --type lib --name [NAME](,[NAME],[NAME])

      atomic-bomb --type domain --name [NAME](,[NAME],[NAME])
      atomic-bomb --type subdomain --for [DOMAIN] --name [NAME](,[NAME],[NAME])

      atomic-bomb --for [DOMAIN]/[SUBDOMAIN] --type atom|molecule|organism|template --name [NAME]
      atomic-bomb --for [DOMAIN]/[SUBDOMAIN] --type api|event|helper|hook|model|page|service|state --name [NAME]

      atomic-bomb --export structure.json
      atomic-bomb --from structure.json
      atomic-bomb --remove [NAME]

      Platforms

      Platforms are pulled from the template repository configured in

      package.json
      :

      JSON
      {
      "config": {
      "templates": "https://github.com/ReneKrewinkel/atomic-bomb-templates.git"
      }
      }

      Use:

      Shell
      atomic-bomb --platform react-ts
      atomic-bomb -p react-ts

      This writes or updates

      .atomic-bomb
      without requiring
      --name
      .

      Available platforms depend on the template repository. See [atomic-bomb-templates](https://github.com/ReneKrewinkel/atomic-bomb-templates).

      Configuration

      Atomic Bomb creates a

      .atomic-bomb
      file in the project root.

      Example:

      JSON
      {
      "search": "react",
      "extension": "tsx",
      "platform": "react-ts",
      "destination": "src/components",
      "scss": true
      }

      Fields:

      • search
        : dependency name to check in
        package.json
      • extension
        : component file extension:
        js
        ,
        jsx
        ,
        ts
        or
        tsx
      • platform
        : default platform used when
        --platform
        is omitted
      • destination
        : component root, usually
        src/components
      • scss
        : whether
        _index.scss
        files are created and updated

      Naming

      Atomic Bomb normalizes names by type.

      Component and container types use

      PascalCase
      :

      • atom
      • molecule
      • organism
      • template
      • page
      • domain
      • subdomain

      Non-component file types use

      camelCase
      :

      • api
      • event
      • helper
      • hook
      • lib
      • model
      • service
      • state

      Examples:

      Shell
      atomic-bomb --type atom --name "data table"
      # DataTable

      atomic-bomb --type hook --name "use data"
      # useData

      atomic-bomb --for Orders/Sales --type event --name "order created"
      # orderCreated

      Existing

      PascalCase
      component names and existing
      camelCase
      non-component names are preserved.

      CLI Output

      Generated output uses icons for the newer structure types:

      • hook
        : 🪝
      • lib
        : 📚
      • domain
        : 🏢
      • subdomain
        : 🗄️

      Atomic Components

      Create one component:

      Shell
      atomic-bomb --type atom --name Label
      atomic-bomb --type molecule --name Header
      atomic-bomb --type organism --name Navigation
      atomic-bomb --type template --name Dashboard
      atomic-bomb --type page --name Home

      Create multiple components:

      Shell
      atomic-bomb --type atom --name Label,Button,Input

      Create a multi-word component:

      Shell
      atomic-bomb --type molecule --name "Button Group"

      Atomic components are created in:

      Shell
      src/components/[type]s/[Name]

      Example output for a React TypeScript component:

      Shell
      src/components/molecules/ButtonGroup
      ├── ButtonGroup.interface.tsx
      ├── ButtonGroup.mock.ts
      ├── ButtonGroup.stories.tsx
      ├── ButtonGroup.test.tsx
      ├── ButtonGroup.tsx
      ├── _ButtonGroup.style.scss
      ├── _index.scss
      └── index.tsx

      Atomic directory indexes are created for each component bucket:

      Shell
      src/components
      ├── index.ts
      ├── atoms
      │ ├── index.tsx
      │ └── _index.scss
      ├── molecules
      │ ├── index.tsx
      │ └── _index.scss
      ├── organisms
      │ ├── index.tsx
      │ └── _index.scss
      ├── templates
      │ ├── index.tsx
      │ └── _index.scss
      └── pages
      ├── index.tsx
      └── _index.scss

      When

      extension
      is
      tsx
      or
      jsx
      , non-component barrel files use the matching logic extension:

      • tsx
        ->
        ts
      • jsx
        ->
        js

      Hooks

      Create hooks next to

      components
      :

      Shell
      atomic-bomb --type hook --name useData

      Output:

      Shell
      src/hooks
      ├── index.ts
      └── useData
      ├── index.ts
      └── useData.ts

      The generated file contains:

      TypeScript
      export const useData = () => {}

      export default useData

      Lib

      Create shared lib files next to

      components
      :

      Shell
      atomic-bomb --type lib --name formatDate

      Output:

      Shell
      src/lib
      ├── index.ts
      └── formatDate
      ├── index.ts
      └── formatDate.ts

      The generated file contains:

      TypeScript
      export const formatDate = () => {}

      export default formatDate

      Domains

      Create a domain directory next to

      components
      :

      Shell
      atomic-bomb --type domain --name Orders

      Output:

      Shell
      src/domains
      ├── index.ts
      └── Orders
      └── index.ts

      src/domains/index.ts
      exports the domain:

      TypeScript
      export * as Orders from './Orders'

      Subdomains

      Create a subdomain inside a domain:

      Shell
      atomic-bomb --type subdomain --for Orders --name Sales

      If the domain does not exist, it is created.

      Output:

      Shell
      src/domains/Orders
      ├── index.ts
      └── Sales
      ├── api
      │ └── index.ts
      ├── components
      │ ├── index.ts
      │ ├── atoms
      │ │ ├── index.tsx
      │ │ └── _index.scss
      │ ├── molecules
      │ │ ├── index.tsx
      │ │ └── _index.scss
      │ ├── organisms
      │ │ ├── index.tsx
      │ │ └── _index.scss
      │ ├── templates
      │ │ ├── index.tsx
      │ │ └── _index.scss
      │ └── pages
      │ ├── index.tsx
      │ └── _index.scss
      ├── events
      │ └── index.ts
      ├── helpers
      │ └── index.ts
      ├── hooks
      │ └── index.ts
      ├── models
      │ └── index.ts
      ├── pages
      │ └── index.ts
      ├── services
      │ └── index.ts
      ├── state
      │ └── index.ts

      The subdomain

      index.ts
      exports every DDD folder:

      TypeScript
      export * from './components'
      export * from './hooks'
      export * from './services'
      export * from './state'
      export * from './models'
      export * from './events'
      export * from './helpers'
      export * from './api'
      export * from './pages'

      Scoped Generation

      Use

      --for [DOMAIN]/[SUBDOMAIN]
      to create files inside a subdomain.

      Atomic component types go into the subdomain

      components
      folder:

      Shell
      atomic-bomb --for Orders/Sales --type atom --name Logo
      atomic-bomb --for Orders/Sales --type molecule --name FilterBar
      atomic-bomb --for Orders/Sales --type organism --name OrdersTable
      atomic-bomb --for Orders/Sales --type template --name SalesDashboard

      Example:

      Shell
      src/domains/Orders/Sales/components/atoms/Logo
      ├── Logo.interface.tsx
      ├── Logo.mock.ts
      ├── Logo.stories.tsx
      ├── Logo.test.tsx
      ├── Logo.tsx
      ├── _Logo.style.scss
      ├── _index.scss
      └── index.tsx

      Scoped domain file types go into their matching folders:

      Shell
      atomic-bomb --for Orders/Sales --type hook --name useOrders
      atomic-bomb --for Orders/Sales --type service --name orderService
      atomic-bomb --for Orders/Sales --type event --name orderCreated
      atomic-bomb --for Orders/Sales --type helper --name formatOrder
      atomic-bomb --for Orders/Sales --type api --name fetchOrders
      atomic-bomb --for Orders/Sales --type model --name order
      atomic-bomb --for Orders/Sales --type state --name orderState
      atomic-bomb --for Orders/Sales --type page --name SalesOverview

      Examples:

      Shell
      src/domains/Orders/Sales/hooks/useOrders
      ├── index.ts
      └── useOrders.ts

      src/domains/Orders/Sales/services/orderService
      ├── index.ts
      └── orderService.ts

      Each folder index is updated:

      TypeScript
      export { default as orderService } from './orderService'

      Scoped generation repairs missing subdomain index files when the subdomain already exists.

      Remove Generated Items

      Remove generated items by name:

      Shell
      atomic-bomb --remove Logo
      atomic-bomb --remove orderService

      The remove command scans generated

      components
      ,
      domains
      ,
      hooks
      , and
      lib
      folders recursively. It removes every matching item directory and cleans matching TypeScript and Sass barrel lines such as:

      TypeScript
      export { default as Logo } from './Logo'
      export * as Orders from './Orders'
      SCSS
      @use './Logo';

      Export Structure

      Export the current generated structure as JSON:

      Shell
      atomic-bomb --export structure.json

      This exports the directory structure, not file contents.

      Example:

      JSON
      {
      "version": 1,
      "platform": "react-ts",
      "items": [
      { "type": "atom", "name": "Logo" },
      { "type": "lib", "name": "formatDate" },
      { "type": "domain", "name": "Orders" },
      { "type": "subdomain", "for": "Orders", "name": "Sales" },
      { "type": "service", "for": "Orders/Sales", "name": "orderService" }
      ]
      }

      Create From Structure

      Create all items listed in a structure file:

      Shell
      atomic-bomb --from structure.json

      The JSON is validated with Zod before generation. Invalid files stop with an error.

      Scoped items must use:

      JSON
      {
      "type": "service",
      "for": "Orders/Sales",
      "name": "orderService"
      }

      Subdomains use a domain-only

      for
      value:

      JSON
      {
      "type": "subdomain",
      "for": "Orders",
      "name": "Sales"
      }

      Testing Without npm Scripts

      Run the test suite directly:

      Shell
      node --test _tests_/*.test.js

      Check syntax directly:

      Shell
      find src _tests_ -maxdepth 1 -name '*.js' -print | sort | xargs -n1 node --check

      Development

      Format files:

      Shell
      npm run nice

      Run tests:

      Shell
      npm test

      Publishing

      Before publishing:

      Shell
      npm whoami
      npm test
      npm pack --dry-run

      Publish:

      Shell
      npm publish

      If publishing from GitHub Actions, make sure the publish workflow trigger matches the release flow. A job guarded by:

      YAML
      if: github.event.pull_request.merged == true

      will be skipped on normal

      push
      or tag events because
      github.event.pull_request
      is not present for those events.

      License

      GPL-1.0-only