Context and guidance for working with the OpenGrammar desktop application codebase
A comprehensive guide for working with OpenGrammar, an open-source Wails v2 desktop application that provides AI-powered text processing using Claude AI.
OpenGrammar implements a BYOK (Bring Your Own Key) architecture with comprehensive multilingual support and custom action capabilities.
```
/
├── main.go # Application entry point, Wails setup
├── app.go # Core backend logic, Claude API integration
├── go.mod # Go dependencies
├── wails.json # Wails project configuration
└── frontend/
├── src/
│ ├── App.tsx # Main React component
│ └── style.css # Tailwind styles
├── wailsjs/ # Auto-generated TypeScript bindings
├── package.json # Frontend dependencies
└── vite.config.ts # Vite configuration
```
**Primary Method**: `ProcessText(text, apiKey, actionType, language) (string, error)`
**Supported Action Types**:
**Response Structure**: All prompts return structured format:
```
ANALYSIS: [explanation]
FINAL RESULT: [processed text]
```
**API Configuration**:
**Key Features**:
```bash
wails dev
```
```bash
cd frontend
npm install
npm run dev # Vite dev server
npm run build # Build TypeScript + Vite
```
When you modify Go backend methods:
1. Wails automatically regenerates TypeScript bindings in `frontend/wailsjs/`
2. Import updated methods from `frontend/wailsjs/go/main/App`
3. Test in dev mode before building
```bash
wails build -platform darwin/universal -upx
wails build -platform windows/amd64 -nsis -upx
wails build -platform linux/amd64 -upx
wails build -platform darwin/universal,windows/amd64,linux/amd64 -upx
wails build -platform darwin/universal -obfuscated -trimpath -upx
```
1. **Go-to-TypeScript Bindings**: Wails generates TypeScript definitions from Go structs automatically
2. **Method Exposure**: Only capitalized (public) Go methods are exposed to frontend
3. **Frontend Embedding**: Frontend assets embedded in binary via `//go:embed all:frontend/dist`
4. **Binding Setup**: Methods must be bound to App struct in `main.go`
1. Split response by `ANALYSIS:` and result section headers
2. Extract text from relevant sections
3. Remove surrounding quotes from final result
4. Fallback to raw response if parsing fails
| File | Purpose |
|------|---------|
| `wails.json` | Wails project settings, build commands, frontend integration |
| `go.mod` | Go dependencies (Wails v2) |
| `frontend/package.json` | React, TypeScript, Vite, Tailwind dependencies |
| `frontend/vite.config.ts` | Vite build configuration |
| `frontend/tailwind.config.js` | Tailwind CSS v3 configuration |
| `frontend/postcss.config.js` | PostCSS configuration for Tailwind |
1. Keep methods public (capitalized) for frontend access
2. Return `(result string, error)` for consistent error handling
3. Test with `wails dev` before building
4. Check generated TypeScript bindings in `frontend/wailsjs/`
1. Import Go methods from `frontend/wailsjs/go/main/App`
2. Handle errors from Go methods properly
3. Use Tailwind classes for styling (avoid custom CSS)
4. Test bilingual strings for both languages
5. Persist user preferences in LocalStorage
1. Add backend method to `app.go`
2. Restart `wails dev` to regenerate bindings
3. Import new method in `App.tsx`
4. Add UI elements with Tailwind styling
5. Update bilingual translations
6. Test error cases
1. Run `npm run build` in `frontend/` first
2. Use appropriate platform flags for target OS
3. Consider `-upx` for compression
4. Test universal builds on both Intel and Apple Silicon
5. Use `-obfuscated -trimpath` for production security
```bash
wails dev # Start dev server
cd frontend && npm run dev # Frontend only
wails build # Current platform
wails build -platform darwin/universal # macOS universal
wails build -platform windows/amd64 # Windows
wails build -platform linux/amd64 # Linux
go mod tidy # Clean dependencies
go build # Build Go app
cd frontend
npm install # Install dependencies
npm run build # Build frontend
```
1. **Initial Setup** - Wails v2 calculator template
2. **AI Integration** - Claude API grammar checker
3. **Multilingual** - English/Indonesian support
4. **UI Enhancement** - Tailwind CSS v3 migration
5. **Custom Actions** - Flexible prompt system
6. **Production** - Universal macOS binary + DMG
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/opengrammar-project-guide/raw