motia 0.6.3-beta.129 → 0.6.3-beta.130-538881

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/cjs/cli.js +3 -87
  2. package/dist/cjs/create/index.d.ts +2 -2
  3. package/dist/cjs/create/index.js +15 -5
  4. package/dist/cjs/create/interactive.d.ts +2 -2
  5. package/dist/cjs/create/interactive.js +15 -12
  6. package/dist/cjs/cursor-rules/dot-files/.claude/CLAUDE.md +224 -0
  7. package/dist/cjs/cursor-rules/dot-files/.claude/README.md +45 -0
  8. package/dist/cjs/cursor-rules/dot-files/.claude/agents/code-reviewer.md +153 -0
  9. package/dist/cjs/cursor-rules/dot-files/.claude/agents/debugger.md +259 -0
  10. package/dist/cjs/cursor-rules/dot-files/.claude/agents/test-runner.md +268 -0
  11. package/dist/cjs/cursor-rules/dot-files/.claude/commands/add-authentication.md +491 -0
  12. package/dist/cjs/cursor-rules/dot-files/.claude/commands/ai-ml-patterns.md +748 -0
  13. package/dist/cjs/cursor-rules/dot-files/.claude/commands/authentication.md +515 -0
  14. package/dist/cjs/cursor-rules/dot-files/.claude/commands/backend-types.md +719 -0
  15. package/dist/cjs/cursor-rules/dot-files/.claude/commands/build-api.md +407 -0
  16. package/dist/cjs/cursor-rules/dot-files/.claude/commands/claude-workflows.md +1032 -0
  17. package/dist/cjs/cursor-rules/dot-files/.claude/commands/complete-backend.md +345 -0
  18. package/dist/cjs/cursor-rules/dot-files/.claude/commands/create-api.md +96 -0
  19. package/dist/cjs/cursor-rules/dot-files/.claude/commands/data-processing.md +977 -0
  20. package/dist/cjs/cursor-rules/dot-files/.claude/commands/integrate-ai.md +852 -0
  21. package/dist/cjs/cursor-rules/dot-files/.claude/commands/javascript-patterns.md +678 -0
  22. package/dist/cjs/cursor-rules/dot-files/.claude/commands/multi-language-workflow.md +756 -0
  23. package/dist/cjs/cursor-rules/dot-files/.claude/commands/multi-language.md +141 -0
  24. package/dist/cjs/cursor-rules/dot-files/.claude/commands/process-background-jobs.md +587 -0
  25. package/dist/cjs/cursor-rules/dot-files/.claude/commands/process-events.md +89 -0
  26. package/dist/cjs/cursor-rules/dot-files/.claude/hooks/pre-commit.sh +84 -0
  27. package/dist/cjs/cursor-rules/dot-files/.claude/settings.json +73 -0
  28. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/ai-agent-patterns.mdc +725 -0
  29. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/api-design-patterns.mdc +740 -0
  30. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/api-steps.mdc +230 -0
  31. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/architecture.mdc +189 -0
  32. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/authentication-patterns.mdc +620 -0
  33. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/background-job-patterns.mdc +628 -0
  34. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/complete-application-patterns.mdc +433 -0
  35. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/complete-backend-generator.mdc +415 -0
  36. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/cron-steps.mdc +257 -0
  37. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/event-steps.mdc +504 -0
  38. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/instructions.mdc +15 -0
  39. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/multi-language-workflows.mdc +1059 -0
  40. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/noop-steps.mdc +57 -0
  41. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/production-deployment.mdc +668 -0
  42. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/realtime-streaming.mdc +656 -0
  43. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/state-management.mdc +371 -0
  44. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/steps.mdc +373 -0
  45. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/testing.mdc +329 -0
  46. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/typescript.mdc +409 -0
  47. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/ui-steps.mdc +90 -0
  48. package/dist/cjs/cursor-rules/dot-files/.cursor/rules/workflow-patterns.mdc +938 -0
  49. package/dist/cjs/cursor-rules/dot-files/AGENTS.md +397 -0
  50. package/dist/cjs/cursor-rules/dot-files/README.md +58 -0
  51. package/dist/cjs/dev.js +1 -1
  52. package/dist/esm/cli.js +3 -84
  53. package/dist/esm/create/index.d.ts +2 -2
  54. package/dist/esm/create/index.js +15 -5
  55. package/dist/esm/create/interactive.d.ts +2 -2
  56. package/dist/esm/create/interactive.js +15 -12
  57. package/dist/esm/cursor-rules/dot-files/.claude/CLAUDE.md +224 -0
  58. package/dist/esm/cursor-rules/dot-files/.claude/README.md +45 -0
  59. package/dist/esm/cursor-rules/dot-files/.claude/agents/code-reviewer.md +153 -0
  60. package/dist/esm/cursor-rules/dot-files/.claude/agents/debugger.md +259 -0
  61. package/dist/esm/cursor-rules/dot-files/.claude/agents/test-runner.md +268 -0
  62. package/dist/esm/cursor-rules/dot-files/.claude/commands/add-authentication.md +491 -0
  63. package/dist/esm/cursor-rules/dot-files/.claude/commands/ai-ml-patterns.md +748 -0
  64. package/dist/esm/cursor-rules/dot-files/.claude/commands/authentication.md +515 -0
  65. package/dist/esm/cursor-rules/dot-files/.claude/commands/backend-types.md +719 -0
  66. package/dist/esm/cursor-rules/dot-files/.claude/commands/build-api.md +407 -0
  67. package/dist/esm/cursor-rules/dot-files/.claude/commands/claude-workflows.md +1032 -0
  68. package/dist/esm/cursor-rules/dot-files/.claude/commands/complete-backend.md +345 -0
  69. package/dist/esm/cursor-rules/dot-files/.claude/commands/create-api.md +96 -0
  70. package/dist/esm/cursor-rules/dot-files/.claude/commands/data-processing.md +977 -0
  71. package/dist/esm/cursor-rules/dot-files/.claude/commands/integrate-ai.md +852 -0
  72. package/dist/esm/cursor-rules/dot-files/.claude/commands/javascript-patterns.md +678 -0
  73. package/dist/esm/cursor-rules/dot-files/.claude/commands/multi-language-workflow.md +756 -0
  74. package/dist/esm/cursor-rules/dot-files/.claude/commands/multi-language.md +141 -0
  75. package/dist/esm/cursor-rules/dot-files/.claude/commands/process-background-jobs.md +587 -0
  76. package/dist/esm/cursor-rules/dot-files/.claude/commands/process-events.md +89 -0
  77. package/dist/esm/cursor-rules/dot-files/.claude/hooks/pre-commit.sh +84 -0
  78. package/dist/esm/cursor-rules/dot-files/.claude/settings.json +73 -0
  79. package/dist/esm/cursor-rules/dot-files/.cursor/rules/ai-agent-patterns.mdc +725 -0
  80. package/dist/esm/cursor-rules/dot-files/.cursor/rules/api-design-patterns.mdc +740 -0
  81. package/dist/esm/cursor-rules/dot-files/.cursor/rules/api-steps.mdc +230 -0
  82. package/dist/esm/cursor-rules/dot-files/.cursor/rules/architecture.mdc +189 -0
  83. package/dist/esm/cursor-rules/dot-files/.cursor/rules/authentication-patterns.mdc +620 -0
  84. package/dist/esm/cursor-rules/dot-files/.cursor/rules/background-job-patterns.mdc +628 -0
  85. package/dist/esm/cursor-rules/dot-files/.cursor/rules/complete-application-patterns.mdc +433 -0
  86. package/dist/esm/cursor-rules/dot-files/.cursor/rules/complete-backend-generator.mdc +415 -0
  87. package/dist/esm/cursor-rules/dot-files/.cursor/rules/cron-steps.mdc +257 -0
  88. package/dist/esm/cursor-rules/dot-files/.cursor/rules/event-steps.mdc +504 -0
  89. package/dist/esm/cursor-rules/dot-files/.cursor/rules/instructions.mdc +15 -0
  90. package/dist/esm/cursor-rules/dot-files/.cursor/rules/multi-language-workflows.mdc +1059 -0
  91. package/dist/esm/cursor-rules/dot-files/.cursor/rules/noop-steps.mdc +57 -0
  92. package/dist/esm/cursor-rules/dot-files/.cursor/rules/production-deployment.mdc +668 -0
  93. package/dist/esm/cursor-rules/dot-files/.cursor/rules/realtime-streaming.mdc +656 -0
  94. package/dist/esm/cursor-rules/dot-files/.cursor/rules/state-management.mdc +371 -0
  95. package/dist/esm/cursor-rules/dot-files/.cursor/rules/steps.mdc +373 -0
  96. package/dist/esm/cursor-rules/dot-files/.cursor/rules/testing.mdc +329 -0
  97. package/dist/esm/cursor-rules/dot-files/.cursor/rules/typescript.mdc +409 -0
  98. package/dist/esm/cursor-rules/dot-files/.cursor/rules/ui-steps.mdc +90 -0
  99. package/dist/esm/cursor-rules/dot-files/.cursor/rules/workflow-patterns.mdc +938 -0
  100. package/dist/esm/cursor-rules/dot-files/AGENTS.md +397 -0
  101. package/dist/esm/cursor-rules/dot-files/README.md +58 -0
  102. package/dist/esm/dev.js +1 -1
  103. package/dist/types/create/index.d.ts +2 -2
  104. package/dist/types/create/interactive.d.ts +2 -2
  105. package/package.json +4 -4
  106. package/dist/cjs/cursor-rules/index.d.ts +0 -8
  107. package/dist/cjs/cursor-rules/index.js +0 -269
  108. package/dist/esm/cursor-rules/index.d.ts +0 -8
  109. package/dist/esm/cursor-rules/index.js +0 -263
  110. package/dist/types/cursor-rules/index.d.ts +0 -8
package/dist/cjs/cli.js CHANGED
@@ -1,15 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
4
  /* eslint-disable @typescript-eslint/no-require-imports */
8
5
  const commander_1 = require("commander");
9
6
  require("./cloud");
10
7
  const version_1 = require("./version");
11
8
  const config_utils_1 = require("./cloud/config-utils");
12
- const inquirer_1 = __importDefault(require("inquirer"));
13
9
  const defaultPort = 3000;
14
10
  const defaultHost = '0.0.0.0';
15
11
  require('dotenv/config');
@@ -28,44 +24,10 @@ commander_1.program
28
24
  .command('create')
29
25
  .description('Create a new motia project')
30
26
  .option('-n, --name <project name>', 'The name for your project, used to create a directory, use ./ or . to create it under the existing directory')
31
- .option('-t, --template <template name>', 'The motia template name to use for your project', 'typescript')
32
- .option('-c, --cursor', 'Copy .cursor folder from template')
33
- .option('-i, --interactive', 'Use interactive prompts to create project')
34
- .option('-y, --skip-confirmation', 'Skip confirmation prompt')
35
- .option('-d, --skip-tutorial [value]', 'Skip the motia tutorial (true/false)')
27
+ .option('-i, --interactive', 'Use interactive prompts to create project') // it's default
36
28
  .action((0, config_utils_1.handler)(async (arg, context) => {
37
- if (arg.name || arg.template || arg.cursor) {
38
- const { create } = require('./create');
39
- // Handle skip-tutorial option: 'true', 'false', or prompt user
40
- const skipTutorialValue = await (async () => {
41
- const skipValue = String(arg.skipTutorial).toLowerCase();
42
- if (skipValue === 'true')
43
- return true;
44
- if (skipValue === 'false')
45
- return false;
46
- // Prompt user when not explicitly set
47
- const { disableTutorial } = await inquirer_1.default.prompt({
48
- type: 'confirm',
49
- name: 'disableTutorial',
50
- message: 'Do you wish to disable the motia tutorial?',
51
- default: false,
52
- });
53
- return disableTutorial;
54
- })();
55
- await create({
56
- projectName: arg.name ?? '.',
57
- template: arg.template,
58
- cursorEnabled: arg.cursor,
59
- context,
60
- skipTutorialTemplates: skipTutorialValue,
61
- });
62
- }
63
- else {
64
- const skipConfirmation = arg.skipConfirmation ?? false;
65
- const { createInteractive } = require('./create/interactive');
66
- await createInteractive({ skipConfirmation }, context);
67
- }
68
- process.exit(0);
29
+ const { createInteractive } = require('./create/interactive');
30
+ await createInteractive({ name: arg.name }, context);
69
31
  }));
70
32
  commander_1.program
71
33
  .command('generate-types')
@@ -75,13 +37,6 @@ commander_1.program
75
37
  await generateTypes(process.cwd());
76
38
  process.exit(0);
77
39
  });
78
- commander_1.program
79
- .command('templates')
80
- .description('Prints the list of available templates')
81
- .action(async () => {
82
- const { templates } = require('./create/templates');
83
- console.log(`📝 Available templates: \n\n ${Object.keys(templates).join('\n')}`);
84
- });
85
40
  commander_1.program
86
41
  .command('install')
87
42
  .description('Sets up Python virtual environment and install dependencies')
@@ -194,44 +149,5 @@ docker
194
149
  await build(arg.projectName);
195
150
  process.exit(0);
196
151
  });
197
- const rules = commander_1.program
198
- .command('rules')
199
- .description('Manage Motia AI development guides (AGENTS.md, CLAUDE.md) and IDE-specific rules');
200
- rules
201
- .command('pull')
202
- .description('Install essential AI development guides (AGENTS.md, CLAUDE.md) and optional Cursor IDE rules')
203
- .option('-f, --force', 'Overwrite existing files')
204
- .action(async (options) => {
205
- const { handleAIGuides } = require('./cursor-rules');
206
- await handleAIGuides({ force: options.force });
207
- });
208
- rules
209
- .command('list')
210
- .description('List available AI development guides and IDE rules')
211
- .action(async () => {
212
- const { handleAIGuides } = require('./cursor-rules');
213
- await handleAIGuides({ list: true });
214
- });
215
- rules
216
- .command('show <rule-name>')
217
- .description('Show content of a specific AI guide or IDE rule')
218
- .action(async (ruleName) => {
219
- const { handleAIGuides } = require('./cursor-rules');
220
- await handleAIGuides({ show: ruleName });
221
- });
222
- rules
223
- .command('remove')
224
- .description('Remove AI development guides and IDE rules from your project')
225
- .action(async () => {
226
- const { handleAIGuides } = require('./cursor-rules');
227
- await handleAIGuides({ remove: true });
228
- });
229
- rules
230
- .command('version')
231
- .description('Show AI development guides version')
232
- .action(async () => {
233
- const { handleAIGuides } = require('./cursor-rules');
234
- await handleAIGuides({ version: true });
235
- });
236
152
  commander_1.program.version(version_1.version, '-V, --version', 'Output the current version');
237
153
  commander_1.program.parse(process.argv);
@@ -1,8 +1,8 @@
1
1
  import { CliContext } from '../cloud/config-utils';
2
2
  type Args = {
3
3
  projectName: string;
4
- template?: string;
5
- cursorEnabled?: boolean;
4
+ template: string;
5
+ cursorEnabled: boolean;
6
6
  context: CliContext;
7
7
  skipTutorialTemplates?: boolean;
8
8
  };
@@ -170,11 +170,21 @@ const create = async ({ projectName, template, cursorEnabled, context }) => {
170
170
  fs_1.default.writeFileSync(path_1.default.join(rootDir, '.gitignore'), gitignoreContent);
171
171
  context.log('gitignore-created', (message) => message.tag('success').append('File').append('.gitignore', 'cyan').append('has been created.'));
172
172
  }
173
- const cursorTemplateDir = path_1.default.join(__dirname, '../../dot-files/.cursor');
174
- const cursorTargetDir = path_1.default.join(rootDir, '.cursor');
175
- if (cursorEnabled && !(0, utils_1.checkIfDirectoryExists)(cursorTargetDir)) {
176
- fs_1.default.cpSync(cursorTemplateDir, cursorTargetDir, { recursive: true });
177
- context.log('cursor-folder-created', (message) => message.tag('success').append('Folder').append('.cursor', 'cyan').append('has been created.'));
173
+ if (cursorEnabled) {
174
+ }
175
+ const cursorTemplateDir = path_1.default.join(__dirname, '..', 'cursor-rules', 'dot-files');
176
+ const files = fs_1.default.readdirSync(cursorTemplateDir);
177
+ for (const file of files) {
178
+ const targetFile = path_1.default.join(rootDir, file);
179
+ if (!(0, utils_1.checkIfDirectoryExists)(targetFile)) {
180
+ const isFolder = fs_1.default.statSync(path_1.default.join(cursorTemplateDir, file)).isDirectory();
181
+ fs_1.default.cpSync(path_1.default.join(cursorTemplateDir, file), targetFile, { recursive: isFolder });
182
+ context.log(`${file}-created`, (message) => message
183
+ .tag('success')
184
+ .append(isFolder ? 'Folder' : 'File')
185
+ .append(file, 'cyan')
186
+ .append('has been created.'));
187
+ }
178
188
  }
179
189
  if (template) {
180
190
  await (0, setup_template_1.setupTemplate)(template, rootDir, context);
@@ -1,6 +1,6 @@
1
1
  import { CliContext } from '../cloud/config-utils';
2
2
  interface CreateInteractiveArgs {
3
- skipConfirmation?: boolean;
3
+ name?: string;
4
4
  }
5
- export declare const createInteractive: (_args: CreateInteractiveArgs, context: CliContext) => Promise<void>;
5
+ export declare const createInteractive: (args: CreateInteractiveArgs, context: CliContext) => Promise<void>;
6
6
  export {};
@@ -11,9 +11,9 @@ const choices = {
11
11
  typescript: 'Base (TypeScript)',
12
12
  python: 'Base (Python)',
13
13
  };
14
- const createInteractive = async (_args, context) => {
14
+ const createInteractive = async (args, context) => {
15
15
  context.log('welcome', (message) => message.append('\n🚀 ' + colors_1.default.bold('Welcome to Motia Project Creator!')));
16
- const answers = await inquirer_1.default.prompt([
16
+ const questions = [
17
17
  {
18
18
  type: 'list',
19
19
  name: 'template',
@@ -23,7 +23,9 @@ const createInteractive = async (_args, context) => {
23
23
  value: key,
24
24
  })),
25
25
  },
26
- {
26
+ ];
27
+ if (!args.name) {
28
+ questions.push({
27
29
  type: 'input',
28
30
  name: 'projectName',
29
31
  message: '2. Project name (leave blank to use current folder):',
@@ -36,21 +38,22 @@ const createInteractive = async (_args, context) => {
36
38
  return true;
37
39
  },
38
40
  filter: (input) => input.trim(),
39
- },
40
- {
41
- type: 'confirm',
42
- name: 'proceed',
43
- message: '3. Proceed? [Y/n]:',
44
- default: true,
45
- },
46
- ]);
41
+ });
42
+ }
43
+ questions.push({
44
+ type: 'confirm',
45
+ name: 'proceed',
46
+ message: '3. Proceed? [Y/n]:',
47
+ default: true,
48
+ });
49
+ const answers = await inquirer_1.default.prompt(questions);
47
50
  if (!answers.proceed) {
48
51
  context.log('cancelled', (message) => message.tag('info').append('\n❌ Project creation cancelled.'));
49
52
  return;
50
53
  }
51
54
  context.log('creating', (message) => message.append('\n🔨 Creating your Motia project...\n'));
52
55
  await (0, index_1.create)({
53
- projectName: answers.projectName || '.',
56
+ projectName: args.name || answers.projectName || '.',
54
57
  template: answers.template,
55
58
  cursorEnabled: true, // Default to true for cursor rules
56
59
  context,
@@ -0,0 +1,224 @@
1
+ # Build ANY Backend with Motia
2
+
3
+ Welcome! This guide helps you build production-ready backends using Motia's unified framework. Whether you're building an e-commerce platform, social network, AI application, or IoT system - Motia handles it all.
4
+
5
+ ## The One Concept You Need: Steps
6
+
7
+ In Motia, everything is a "Step":
8
+ - **API endpoints** → API steps
9
+ - **Background jobs** → Event steps
10
+ - **Scheduled tasks** → Cron steps
11
+ - **External webhooks** → Noop steps
12
+
13
+ That's it. Master this one concept and you can build anything.
14
+
15
+ ## Choose Your Language Based on the Task
16
+
17
+ ```
18
+ JavaScript → Quick APIs, prototypes, real-time features
19
+ TypeScript → Enterprise APIs, complex business logic
20
+ Python → AI/ML, data science, image processing
21
+ Ruby → Reports, data exports, file manipulation
22
+ ```
23
+
24
+ ## Quick Start Commands
25
+
26
+ ```bash
27
+ # Start any backend in 30 seconds
28
+ motia create my-backend
29
+ cd my-backend
30
+ motia dev
31
+
32
+ # Your backend is now running at http://localhost:5173
33
+ ```
34
+
35
+ ## Build Your Backend - Step by Step
36
+
37
+ ### 1. Need a REST API?
38
+ See `commands/build-api.md`
39
+
40
+ ### 2. Need Authentication?
41
+ See `commands/add-authentication.md`
42
+
43
+ ### 3. Need Background Jobs?
44
+ See `commands/process-background-jobs.md`
45
+
46
+ ### 4. Need Real-time Features?
47
+ See `commands/add-realtime.md`
48
+
49
+ ### 5. Need AI/ML Processing?
50
+ See `commands/integrate-ai.md`
51
+
52
+ ### 6. Need Data Processing?
53
+ See `commands/process-data.md`
54
+
55
+ ## Complete Application Templates
56
+
57
+ ### E-commerce Backend
58
+ ```bash
59
+ motia generate ecommerce
60
+ # Includes: cart, payments, inventory, recommendations
61
+ ```
62
+
63
+ ### SaaS Platform
64
+ ```bash
65
+ motia generate saas
66
+ # Includes: multi-tenant, billing, admin, analytics
67
+ ```
68
+
69
+ ### Real-time Chat
70
+ ```bash
71
+ motia generate chat
72
+ # Includes: rooms, messages, presence, history
73
+ ```
74
+
75
+ ### AI Application
76
+ ```bash
77
+ motia generate ai-app
78
+ # Includes: LLM integration, embeddings, RAG
79
+ ```
80
+
81
+ ## Core Pattern: API → Process → Respond
82
+
83
+ Here's how different languages work together in Motia:
84
+
85
+ ```javascript
86
+ // Step 1: API endpoint (JavaScript - quick & simple)
87
+ // steps/api/submit-form.step.js
88
+ exports.config = {
89
+ type: 'api',
90
+ method: 'POST',
91
+ path: '/submit',
92
+ emits: ['form.submitted']
93
+ }
94
+
95
+ exports.handler = async (req, { emit }) => {
96
+ await emit({
97
+ topic: 'form.submitted',
98
+ data: req.body
99
+ })
100
+ return { status: 200, body: { message: 'Processing...' } }
101
+ }
102
+ ```
103
+
104
+ ```python
105
+ # Step 2: Process with AI (Python - best for ML)
106
+ # steps/process_form_step.py
107
+ config = {
108
+ "type": "event",
109
+ "subscribes": ["form.submitted"],
110
+ "emits": ["email.send"]
111
+ }
112
+
113
+ async def handler(input_data, ctx):
114
+ # AI processing here
115
+ result = analyze_sentiment(input_data["message"])
116
+
117
+ await ctx.emit({
118
+ "topic": "email.send",
119
+ "data": {
120
+ "to": input_data["email"],
121
+ "sentiment": result
122
+ }
123
+ })
124
+ ```
125
+
126
+ ```ruby
127
+ # Step 3: Generate and send email (Ruby - great for templates)
128
+ # steps/send_email.step.rb
129
+ def config
130
+ {
131
+ type: 'event',
132
+ subscribes: ['email.send'],
133
+ emits: ['email.sent']
134
+ }
135
+ end
136
+
137
+ def handler(input, context)
138
+ html = generate_email_template(input)
139
+ send_email(input['to'], html)
140
+
141
+ context.emit(
142
+ topic: 'email.sent',
143
+ data: { recipient: input['to'] }
144
+ )
145
+ end
146
+ ```
147
+
148
+ ## Production Checklist
149
+
150
+ - [ ] Add authentication (`commands/add-authentication.md`)
151
+ - [ ] Set up error handling (`commands/handle-errors.md`)
152
+ - [ ] Configure rate limiting (`commands/add-rate-limiting.md`)
153
+ - [ ] Add monitoring (`commands/add-monitoring.md`)
154
+ - [ ] Deploy to production (`commands/deploy.md`)
155
+
156
+ ## Project Structure
157
+
158
+ ```
159
+ your-app/
160
+ ├── steps/ # All your code goes here
161
+ │ ├── api/ # API endpoints
162
+ │ ├── events/ # Background jobs
163
+ │ ├── cron/ # Scheduled tasks
164
+ │ └── integrations/ # External webhooks
165
+ ├── package.json # JavaScript dependencies
166
+ ├── requirements.txt # Python dependencies
167
+ └── Gemfile # Ruby dependencies
168
+ ```
169
+
170
+ ## Common Questions
171
+
172
+ **Q: Which language should I use?**
173
+ A: Use the language that best fits the task:
174
+ - APIs & web logic → JavaScript/TypeScript
175
+ - AI & data science → Python
176
+ - Reports & file processing → Ruby
177
+
178
+ **Q: How do I handle errors?**
179
+ A: Every example includes error handling. Copy the patterns.
180
+
181
+ **Q: Can I use my favorite npm/pip/gem packages?**
182
+ A: Yes! Just add them to package.json, requirements.txt, or Gemfile.
183
+
184
+ **Q: How do I scale?**
185
+ A: Motia scales horizontally. Just run more instances.
186
+
187
+ ## Quick Reference
188
+
189
+ ### Building Features
190
+ - **Build API**: `commands/build-api.md`
191
+ - **Add Auth**: `commands/add-authentication.md`
192
+ - **Background Jobs**: `commands/process-background-jobs.md`
193
+ - **Real-time**: `commands/add-realtime.md`
194
+ - **AI/ML**: `commands/integrate-ai.md`
195
+ - **Data Processing**: `commands/process-data.md`
196
+
197
+ ### Complete Examples
198
+ - **Full Backend**: `commands/complete-backend.md`
199
+ - **Backend Types**: `commands/backend-types.md`
200
+ - **Multi-language**: `commands/multi-language-workflow.md`
201
+
202
+ ### Help & Tools
203
+ - **Debug Issues**: `agents/debugger.md`
204
+ - **Review Code**: `agents/code-reviewer.md`
205
+ - **Write Tests**: `agents/test-runner.md`
206
+
207
+ ## Get Started Now
208
+
209
+ Don't overthink it. Pick a template, copy the code, and start building. Motia handles the complex stuff so you can focus on your business logic.
210
+
211
+ ```bash
212
+ # Your backend in 3 commands
213
+ motia create awesome-app
214
+ cd awesome-app
215
+ motia dev
216
+
217
+ # You're ready to build!
218
+ ```
219
+
220
+ ## Resources
221
+
222
+ - Documentation: https://motia.dev/docs
223
+ - Examples: https://github.com/MotiaDev/motia-examples
224
+ - Discord: https://discord.gg/motia
@@ -0,0 +1,45 @@
1
+ # Claude Assistant Configuration for Motia
2
+
3
+ This directory contains AI assistant configuration following the Claude Code directory structure.
4
+
5
+ ## Directory Structure
6
+
7
+ ```
8
+ .claude/
9
+ ├── CLAUDE.md # Main instructions and overview
10
+ ├── commands/ # Slash commands for common tasks
11
+ │ ├── create-api.md
12
+ │ ├── process-events.md
13
+ │ ├── multi-language.md
14
+ │ └── deploy.md
15
+ ├── agents/ # Specialized AI agents
16
+ │ ├── code-reviewer.md
17
+ │ ├── test-runner.md
18
+ │ └── debugger.md
19
+ ├── hooks/ # Lifecycle automation scripts
20
+ │ ├── pre-commit.sh
21
+ │ └── post-deploy.sh
22
+ └── settings.json # Configuration and preferences
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ When working with Claude on Motia projects:
28
+
29
+ 1. Claude will automatically reference `CLAUDE.md` for context
30
+ 2. Use slash commands like `/create-api` to trigger specific patterns
31
+ 3. Agents activate automatically based on keywords (e.g., "review", "test", "debug")
32
+ 4. Hooks can be integrated with your git and deployment workflows
33
+
34
+ ## Customization
35
+
36
+ Feel free to:
37
+ - Add new command patterns in `commands/`
38
+ - Create specialized agents in `agents/`
39
+ - Modify `settings.json` for your preferences
40
+ - Update `CLAUDE.md` with project-specific context
41
+
42
+ ## Learn More
43
+
44
+ - [Motia Documentation](https://motia.dev/docs)
45
+ - [Claude Code Documentation](https://docs.anthropic.com/en/docs/claude-code)
@@ -0,0 +1,153 @@
1
+ # Code Reviewer Agent
2
+
3
+ Specialized agent for reviewing Motia code for best practices, security, and performance.
4
+
5
+ ## Review Checklist
6
+
7
+ ### Step Configuration
8
+ - [ ] Correct step type (api/event/cron/noop)
9
+ - [ ] Descriptive step name
10
+ - [ ] Input/output schemas defined with Zod
11
+ - [ ] Appropriate events emitted
12
+ - [ ] Middleware applied correctly
13
+
14
+ ### Code Quality
15
+ - [ ] Error handling with try-catch
16
+ - [ ] Structured logging with context
17
+ - [ ] No hardcoded values
18
+ - [ ] DRY principle followed
19
+ - [ ] Functions are focused and small
20
+
21
+ ### Security
22
+ - [ ] Input validation on all endpoints
23
+ - [ ] Authentication required where needed
24
+ - [ ] No sensitive data in logs
25
+ - [ ] SQL injection prevention
26
+ - [ ] XSS protection
27
+
28
+ ### Performance
29
+ - [ ] No blocking operations
30
+ - [ ] Efficient state queries
31
+ - [ ] Proper use of caching
32
+ - [ ] Batch operations where appropriate
33
+ - [ ] Connection pooling
34
+
35
+ ### TypeScript Specific
36
+ ```typescript
37
+ // Good ✓
38
+ export const handler: Handlers['StepName'] = async (req, { emit, logger, state }) => {
39
+ try {
40
+ // Validate
41
+ if (!req.body.userId) {
42
+ return { status: 400, body: { error: 'userId required' } }
43
+ }
44
+
45
+ // Process
46
+ const result = await processData(req.body)
47
+
48
+ // Emit event
49
+ await emit({ topic: 'data.processed', data: result })
50
+
51
+ // Log success
52
+ logger.info('Processing complete', { userId: req.body.userId })
53
+
54
+ return { status: 200, body: result }
55
+ } catch (error) {
56
+ logger.error('Processing failed', { error: error.message })
57
+ return { status: 500, body: { error: 'Internal error' } }
58
+ }
59
+ }
60
+
61
+ // Bad ✗
62
+ export const handler = async (req, ctx) => {
63
+ const data = await processData(req.body) // No error handling
64
+ console.log(data) // Using console.log
65
+ return data // Wrong return format
66
+ }
67
+ ```
68
+
69
+ ### Python Specific
70
+ ```python
71
+ # Good ✓
72
+ async def handler(input_data, ctx):
73
+ try:
74
+ # Validate input
75
+ if not input_data.get("userId"):
76
+ raise ValueError("userId required")
77
+
78
+ # Process
79
+ result = process_data(input_data)
80
+
81
+ # Emit event
82
+ await ctx.emit({
83
+ "topic": "data.processed",
84
+ "data": result
85
+ })
86
+
87
+ ctx.logger.info("Processing complete", extra={"userId": input_data["userId"]})
88
+
89
+ except Exception as e:
90
+ ctx.logger.error(f"Processing failed: {str(e)}")
91
+ raise
92
+
93
+ # Bad ✗
94
+ def handler(input, ctx): # Not async
95
+ data = process(input)
96
+ print(data) # Using print
97
+ return data # Returning instead of emitting
98
+ ```
99
+
100
+ ### Common Issues
101
+
102
+ 1. **Missing Error Handling**
103
+ - Always wrap in try-catch
104
+ - Log errors with context
105
+ - Return appropriate status codes
106
+
107
+ 2. **Poor State Management**
108
+ - Use consistent key patterns
109
+ - Set TTL for temporary data
110
+ - Clean up after processing
111
+
112
+ 3. **Event Anti-patterns**
113
+ - Avoid circular dependencies
114
+ - Don't emit too many events
115
+ - Keep event data minimal
116
+
117
+ 4. **Security Vulnerabilities**
118
+ - Never trust user input
119
+ - Sanitize all outputs
120
+ - Use parameterized queries
121
+
122
+ ## Review Comments Template
123
+
124
+ ```
125
+ ### Code Review: [Step Name]
126
+
127
+ **Overall**: [Good/Needs Work/Critical Issues]
128
+
129
+ **Strengths**:
130
+ - ✓ [Positive aspect]
131
+ - ✓ [Another good point]
132
+
133
+ **Issues Found**:
134
+ - ⚠️ **[Category]**: [Description]
135
+ ```typescript
136
+ // Current code
137
+ ```
138
+ **Suggestion**:
139
+ ```typescript
140
+ // Improved code
141
+ ```
142
+
143
+ **Security Concerns**:
144
+ - 🔒 [Any security issues]
145
+
146
+ **Performance Considerations**:
147
+ - ⚡ [Performance improvements]
148
+
149
+ **Recommended Actions**:
150
+ 1. [High priority fix]
151
+ 2. [Medium priority improvement]
152
+ 3. [Nice to have enhancement]
153
+ ```