motia 0.6.3-beta.130-601955 → 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.
- package/dist/cjs/cli.js +0 -39
- package/dist/cjs/create/index.d.ts +2 -2
- package/dist/cjs/create/index.js +15 -5
- package/dist/cjs/cursor-rules/dot-files/.claude/CLAUDE.md +224 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/README.md +45 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/agents/code-reviewer.md +153 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/agents/debugger.md +259 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/agents/test-runner.md +268 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/add-authentication.md +491 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/ai-ml-patterns.md +748 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/authentication.md +515 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/backend-types.md +719 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/build-api.md +407 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/claude-workflows.md +1032 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/complete-backend.md +345 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/create-api.md +96 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/data-processing.md +977 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/integrate-ai.md +852 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/javascript-patterns.md +678 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/multi-language-workflow.md +756 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/multi-language.md +141 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/process-background-jobs.md +587 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/commands/process-events.md +89 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/hooks/pre-commit.sh +84 -0
- package/dist/cjs/cursor-rules/dot-files/.claude/settings.json +73 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/ai-agent-patterns.mdc +725 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/api-design-patterns.mdc +740 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/api-steps.mdc +230 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/architecture.mdc +189 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/authentication-patterns.mdc +620 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/background-job-patterns.mdc +628 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/complete-application-patterns.mdc +433 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/complete-backend-generator.mdc +415 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/cron-steps.mdc +257 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/event-steps.mdc +504 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/instructions.mdc +15 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/multi-language-workflows.mdc +1059 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/noop-steps.mdc +57 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/production-deployment.mdc +668 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/realtime-streaming.mdc +656 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/state-management.mdc +371 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/steps.mdc +373 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/testing.mdc +329 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/typescript.mdc +409 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/ui-steps.mdc +90 -0
- package/dist/cjs/cursor-rules/dot-files/.cursor/rules/workflow-patterns.mdc +938 -0
- package/dist/cjs/cursor-rules/dot-files/AGENTS.md +397 -0
- package/dist/cjs/cursor-rules/dot-files/README.md +58 -0
- package/dist/esm/cli.js +0 -39
- package/dist/esm/create/index.d.ts +2 -2
- package/dist/esm/create/index.js +15 -5
- package/dist/esm/cursor-rules/dot-files/.claude/CLAUDE.md +224 -0
- package/dist/esm/cursor-rules/dot-files/.claude/README.md +45 -0
- package/dist/esm/cursor-rules/dot-files/.claude/agents/code-reviewer.md +153 -0
- package/dist/esm/cursor-rules/dot-files/.claude/agents/debugger.md +259 -0
- package/dist/esm/cursor-rules/dot-files/.claude/agents/test-runner.md +268 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/add-authentication.md +491 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/ai-ml-patterns.md +748 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/authentication.md +515 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/backend-types.md +719 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/build-api.md +407 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/claude-workflows.md +1032 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/complete-backend.md +345 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/create-api.md +96 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/data-processing.md +977 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/integrate-ai.md +852 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/javascript-patterns.md +678 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/multi-language-workflow.md +756 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/multi-language.md +141 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/process-background-jobs.md +587 -0
- package/dist/esm/cursor-rules/dot-files/.claude/commands/process-events.md +89 -0
- package/dist/esm/cursor-rules/dot-files/.claude/hooks/pre-commit.sh +84 -0
- package/dist/esm/cursor-rules/dot-files/.claude/settings.json +73 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/ai-agent-patterns.mdc +725 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/api-design-patterns.mdc +740 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/api-steps.mdc +230 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/architecture.mdc +189 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/authentication-patterns.mdc +620 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/background-job-patterns.mdc +628 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/complete-application-patterns.mdc +433 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/complete-backend-generator.mdc +415 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/cron-steps.mdc +257 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/event-steps.mdc +504 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/instructions.mdc +15 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/multi-language-workflows.mdc +1059 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/noop-steps.mdc +57 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/production-deployment.mdc +668 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/realtime-streaming.mdc +656 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/state-management.mdc +371 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/steps.mdc +373 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/testing.mdc +329 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/typescript.mdc +409 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/ui-steps.mdc +90 -0
- package/dist/esm/cursor-rules/dot-files/.cursor/rules/workflow-patterns.mdc +938 -0
- package/dist/esm/cursor-rules/dot-files/AGENTS.md +397 -0
- package/dist/esm/cursor-rules/dot-files/README.md +58 -0
- package/dist/types/create/index.d.ts +2 -2
- package/package.json +4 -4
- package/dist/cjs/cursor-rules/index.d.ts +0 -8
- package/dist/cjs/cursor-rules/index.js +0 -269
- package/dist/esm/cursor-rules/index.d.ts +0 -8
- package/dist/esm/cursor-rules/index.js +0 -263
- package/dist/types/cursor-rules/index.d.ts +0 -8
package/dist/cjs/cli.js
CHANGED
|
@@ -149,44 +149,5 @@ docker
|
|
|
149
149
|
await build(arg.projectName);
|
|
150
150
|
process.exit(0);
|
|
151
151
|
});
|
|
152
|
-
const rules = commander_1.program
|
|
153
|
-
.command('rules')
|
|
154
|
-
.description('Manage Motia AI development guides (AGENTS.md, CLAUDE.md) and IDE-specific rules');
|
|
155
|
-
rules
|
|
156
|
-
.command('pull')
|
|
157
|
-
.description('Install essential AI development guides (AGENTS.md, CLAUDE.md) and optional Cursor IDE rules')
|
|
158
|
-
.option('-f, --force', 'Overwrite existing files')
|
|
159
|
-
.action(async (options) => {
|
|
160
|
-
const { handleAIGuides } = require('./cursor-rules');
|
|
161
|
-
await handleAIGuides({ force: options.force });
|
|
162
|
-
});
|
|
163
|
-
rules
|
|
164
|
-
.command('list')
|
|
165
|
-
.description('List available AI development guides and IDE rules')
|
|
166
|
-
.action(async () => {
|
|
167
|
-
const { handleAIGuides } = require('./cursor-rules');
|
|
168
|
-
await handleAIGuides({ list: true });
|
|
169
|
-
});
|
|
170
|
-
rules
|
|
171
|
-
.command('show <rule-name>')
|
|
172
|
-
.description('Show content of a specific AI guide or IDE rule')
|
|
173
|
-
.action(async (ruleName) => {
|
|
174
|
-
const { handleAIGuides } = require('./cursor-rules');
|
|
175
|
-
await handleAIGuides({ show: ruleName });
|
|
176
|
-
});
|
|
177
|
-
rules
|
|
178
|
-
.command('remove')
|
|
179
|
-
.description('Remove AI development guides and IDE rules from your project')
|
|
180
|
-
.action(async () => {
|
|
181
|
-
const { handleAIGuides } = require('./cursor-rules');
|
|
182
|
-
await handleAIGuides({ remove: true });
|
|
183
|
-
});
|
|
184
|
-
rules
|
|
185
|
-
.command('version')
|
|
186
|
-
.description('Show AI development guides version')
|
|
187
|
-
.action(async () => {
|
|
188
|
-
const { handleAIGuides } = require('./cursor-rules');
|
|
189
|
-
await handleAIGuides({ version: true });
|
|
190
|
-
});
|
|
191
152
|
commander_1.program.version(version_1.version, '-V, --version', 'Output the current version');
|
|
192
153
|
commander_1.program.parse(process.argv);
|
package/dist/cjs/create/index.js
CHANGED
|
@@ -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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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);
|
|
@@ -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
|
+
```
|