DocsCLIGenerate Model

Generate Model

Generates a new model with all the boilerplate files: actions, reducer, epics, selectors, and an index barrel export. The model is also automatically registered in your models index file.


Usage

Interactive:

remodel
# then select "Create Model"

Non-interactive:

remodel generate model --name user --ts --dir ./src/models

Short alias:

remodel g model --name user --ts

Options

FlagTypeDefaultDescription
--name <name>string(required)Model name (e.g., user, product)
--dir <directory>stringfrom .remodel configDirectory where models live
--tsbooleanfrom configUse TypeScript
--jsbooleanfrom configUse JavaScript
💡

If a .remodel config file exists, the CLI reads language and modelsDirectory from it. You only need to pass --name.


Generated Files

Running remodel generate model --name user --ts --dir ./src/models creates:

      • index.ts
        • actions.ts
        • index.ts
        • reducer.ts
        • epics.ts
        • selectors.ts

The model name is automatically pluralized for the folder name (user becomes users, category becomes categories).


Auto-Registration

When a models index file (index.ts or index.js) exists in the target directory, the CLI automatically updates it to import and register the new model.

Before:

src/models/index.ts
import type { ModelProps } from '@blue-functor/remodel';
 
const config: ModelProps = {
  reducers: {},
  epics: {},
};
 
export default config;

After generating user and product models:

src/models/index.ts
import type { ModelProps } from '@blue-functor/remodel';
 
import * as users from './users';
import * as products from './products';
 
const config: ModelProps = {
  reducers: {
    users: users.reducer,
    products: products.reducer,
  },
  epics: {
    users: users.epics,
    products: products.epics,
  },
};
 
export default config;

Each model’s reducer and epics are imported and added to the config object. No manual wiring required.


Generated File Contents

actions.ts

src/models/users/actions.ts
import { generateScopedActions } from '@blue-functor/remodel';
 
const { createAction, createEffectAction } = generateScopedActions('USERS');
 
export { createAction, createEffectAction };

Provides scoped action creators. All actions created in this file are automatically prefixed with USERS/.

reducer.ts

src/models/users/reducer.ts
import { createReducer } from '@reduxjs/toolkit';
import * as actions from './actions';
 
const initState = {};
 
const reducer = createReducer(initState, (builder) => builder);
 
export default reducer;

epics.ts

src/models/users/epics.ts
import { combineEpics } from 'redux-observable';
 
const epics = combineEpics(
  // Add epics here
);
 
export default epics;

selectors.ts

src/models/users/selectors.ts
// Add your selectors here
// Example:
// export const selectData = (state: RootState) => state.yourModel.data;

index.ts

src/models/users/index.ts
export { default as reducer } from './reducer';
export { default as epics } from './epics';
export * from './selectors';
export * from './actions';

Barrel file that re-exports everything from the model.


Interactive Flow

When running interactively, the Create Model screen walks you through:

  1. Model name — text input with validation (must start with a letter, alphanumeric only)
  2. Directory — uses config default or shows a directory picker with filesystem autocomplete
  3. Language — skipped if .remodel config has a language set
  4. Generate — creates the files and updates the models index
  5. Success — shows a summary of all created files