moldable
Moldable App Development
This skill provides comprehensive knowledge for building and modifying apps within the Moldable desktop application.
Quick Reference
| Resource | Path |
|---|---|
| App source code | ~/.moldable/shared/apps/{app-id}/ |
| App runtime data | ~/.moldable/workspaces/{workspace-id}/apps/{app-id}/data/ |
| Workspace config | ~/.moldable/workspaces/{workspace-id}/config.json |
| MCP config | ~/.moldable/shared/config/mcp.json |
| Skills | ~/.moldable/shared/skills/{repo}/{skill}/ |
| Environment | ~/.moldable/shared/.env |
Default Tech Stack
- Framework: Next.js 16 + React 19 + TypeScript
- Styling: Tailwind CSS 4 + shadcn/ui (semantic colors only)
- State: TanStack Query v5
- Storage: Filesystem via
@moldable-ai/storage - Package Manager: pnpm
Creating Apps
ALWAYS use the scaffoldApp tool ā never create app files manually.
scaffoldApp({
appId: "expense-tracker", // lowercase, hyphens only
name: "Expense Tracker", // Display name
icon: "š°", // Emoji icon
description: "Track expenses and generate reports",
widgetSize: "medium", // small, medium, or large
extraDependencies: { // Optional npm packages
"zod": "^3.0.0"
}
})
After scaffolding, customize:
src/app/page.tsxā Main app viewsrc/app/widget/page.tsxā Widget viewsrc/app/api/ā API routessrc/components/ā React components
Detailed References
Read these for in-depth guidance:
Core Concepts
- references/app-lifecycle.md ā Creating, starting, managing, and deleting apps
- references/app-scaffold.md ā Required files, lint rules, templates for new apps
- references/workspaces.md ā Workspace system, data isolation, environment layering
- references/configuration.md ā moldable.json, config.json, environment variables
Implementation Patterns
- references/ui.md ā @moldable-ai/ui components, shadcn/ui, themes, rich text editor
- references/storage-patterns.md ā Filesystem storage, React Query, workspace-aware APIs
- references/desktop-apis.md ā postMessage APIs (open-url, show-in-folder, set-chat-input, save-file)
- references/skills-mcps.md ā Skills library, MCP configuration, custom MCP servers
Essential Patterns
1. UI Components (@moldable-ai/ui)
Always use @moldable-ai/ui for all UI work. It includes shadcn/ui components, theme support, and a rich text editor.
// Import components from @moldable-ai/ui (NOT from shadcn directly)
import {
Button, Card, Input, Dialog, Select, Tabs,
ThemeProvider, WorkspaceProvider, useTheme,
Markdown, CodeBlock, WidgetLayout,
downloadFile, sendToMoldable
} from '@moldable-ai/ui'
// For rich text editing
import { MarkdownEditor } from '@moldable-ai/editor'
Use semantic colors only:
// ā
Correct
<div className="bg-background text-foreground border-border" />
<Button className="bg-primary text-primary-foreground" />
// ā Wrong - raw colors don't adapt to theme
<div className="bg-white text-gray-900" />
See references/ui.md for complete component list and usage.
2. Workspace-Aware Storage
All apps must isolate data per workspace:
// Client - use workspaceId in query keys
const { workspaceId, fetchWithWorkspace } = useWorkspace()
const { data } = useQuery({
queryKey: ['items', workspaceId], // ā Include workspace!
queryFn: () => fetchWithWorkspace('/api/items').then(r => r.json())
})
// Server - extract workspace from request
import { getWorkspaceFromRequest, getAppDataDir } from '@moldable-ai/storage'
export async function GET(request: Request) {
const workspaceId = getWorkspaceFromRequest(request)
const dataDir = getAppDataDir(workspaceId)
// Read/write files in dataDir
}
3. Desktop Integration
Apps communicate with Moldable desktop via postMessage:
// Open external URL
window.parent.postMessage({ type: 'moldable:open-url', url: 'https://...' }, '*')
// Show file in Finder
window.parent.postMessage({ type: 'moldable:show-in-folder', path: '/path/to/file' }, '*')
// Pre-populate chat input
window.parent.postMessage({ type: 'moldable:set-chat-input', text: 'Help me...' }, '*')
// Provide context to AI
window.parent.postMessage({
type: 'moldable:set-chat-instructions',
text: 'User is viewing meeting #123...'
}, '*')
4. Layout Setup
Required providers for Moldable apps:
// src/app/layout.tsx
import { ThemeProvider, WorkspaceProvider } from '@moldable-ai/ui'
import { QueryProvider } from '@/lib/query-provider'
export default function RootLayout({ children }) {
return (
<html lang="en" suppressHydrationWarning>
<body>
<ThemeProvider>
<WorkspaceProvider>
<QueryProvider>{children}</QueryProvider>
</WorkspaceProvider>
</ThemeProvider>
</body>
</html>
)
}
5. Adding Dependencies
Use sandbox: false for package manager commands:
await runCommand({
command: 'cd ~/.moldable/shared/apps/my-app && pnpm add zod',
sandbox: false // Required for network access
})
App Management Tools
| Tool | Purpose | Reversible |
|---|---|---|
scaffoldApp |
Create new app | ā |
getAppInfo |
Check which workspaces use an app | ā |
unregisterApp |
Remove from current workspace only | ā Re-add later |
deleteAppData |
Delete app's data (keep installed) | ā Data lost |
deleteApp |
Permanently delete from ALL workspaces | ā Everything lost |
File Structure
~/.moldable/
āāā shared/
ā āāā apps/{app-id}/ # App source code
ā ā āāā moldable.json # App manifest
ā ā āāā package.json
ā ā āāā src/
ā āāā skills/{repo}/{skill}/ # Skills library
ā āāā mcps/{mcp-name}/ # Custom MCP servers
ā āāā config/mcp.json # Shared MCP config
ā
āāā workspaces/{workspace-id}/
āāā config.json # Registered apps
āāā .env # Workspace env overrides
āāā apps/{app-id}/data/ # App runtime data
āāā conversations/ # Chat history
Common Mistakes to Avoid
- ā Creating apps manually ā Always use
scaffoldApp - ā Using localStorage ā Use filesystem storage
- ā Forgetting workspaceId ā Include in query keys and API calls
- ā Hardcoding paths ā Use
getAppDataDir()for portability - ā Using raw colors ā Use shadcn semantic colors (
bg-background, notbg-gray-100) - ā Running pnpm with sandbox ā Set
sandbox: falsefor network access
Study Existing Apps
For complex features, reference apps in ~/.moldable/shared/apps/:
- scribo ā Translation journal with language selection
- meetings ā Audio recording with real-time transcription
- calendar ā Google Calendar integration with OAuth
These demonstrate data fetching, storage patterns, API routes, and UI components.