CLI Internals
Blueprint Actions
Best Practices

Blueprint Action Best Practices

Patterns & Anti-Patterns

Guidelines for using blueprint actions effectively.


Best Practices

1. Use Semantic Actions

Do:

{ type: 'CREATE_FILE', path: 'file.ts', content: '...' }

Don't:

fs.writeFileSync('file.ts', '...');

2. Use Modifiers for Complex Operations

Do:

{ type: 'ENHANCE_FILE', modifier: 'ts-module-enhancer', params: {...} }

Don't:

const content = fs.readFileSync(...);
const modified = content.replace(/regex/, ...);  // Fragile!
fs.writeFileSync(..., modified);

3. Use forEach for Repeated Actions

Do:

{
  type: 'CREATE_FILE',
  forEach: 'module.parameters.components',
  path: 'components/{{item}}.tsx'
}

Don't:

config.components.forEach(comp => {
  actions.push({ type: 'CREATE_FILE', path: `components/${comp}.tsx` });
});

Next: Advanced Patterns →