glaze-app-dev
Build, edit, run, and debug Glaze (Raycast) desktop apps directly from Claude Code, for free, using your own Claude subscription instead of Glaze's paid…
Give Glaze app users a choice of AI engine - built-in Glaze AI (zero setup, uses their Glaze credits), their own free API key (Google Gemini free tier, optionally OpenRouter free models), or their local Claude Code CLI (their Claude subscription). Use whenever an app built with
$ npx -y skills add GaimsDevSoftware/glaze-coder --skill glaze-byok-ai --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/glaze-byok-aiContext preview
The summary Claude sees to decide when to auto-load this skill.
Give Glaze app users a choice of AI engine - built-in Glaze AI (zero setup, uses their Glaze credits), their own free API key (Google Gemini free tier, optionally OpenRouter free models), or their local Claude Code CLI (their Claude subscription). Use whenever an app built with
name: glaze-byok-ai description: Give Glaze app users a choice of AI engine - built-in Glaze AI (zero setup, uses their Glaze credits), their own free API key (Google Gemini free tier, optionally OpenRouter free models), or their local Claude Code CLI (their Claude subscription). Use whenever an app built with glaze-coder gets an AI feature, so end users can decide whether using the app costs them anything. Covers the provider service, encrypted key storage, the Claude CLI engine, IPC handlers, settings UI, and blocked-state fallback.
Before scaffolding, read the developer's saved policy if present: `~/.config/glaze-coder/defaults.json` with `{"aiDefault": "glaze" | "byok-fallback" | "byok-first"}` (written by the Free Coder for Glaze onboarding app). `byok-fallback` = Glaze default + auto-fallback on (this skill's default); `byok-first` = scaffold with a free engine as the app's default provider and Glaze never running unasked; `glaze` = built-in AI only, skip the engine picker. A missing file means `byok-fallback`.
Default policy for apps built with glaze-coder: when an app calls AI, the end user gets to pick the engine. Glaze AI works with zero setup but spends the user's Glaze credits; a bring-your-own-key engine is free for them (Gemini has a real free tier); the local Claude Code CLI is free for users who already pay for a Claude subscription. Implement this choice unless the user building the app explicitly wants Glaze-only.
Reference implementation: the News Flow app (`ai-provider.ts` + `claude-cli.ts` + "AI-motor" settings section + onboarding engine step). This file contains everything needed to reproduce it in any app.
| Engine | Cost for the user | Setup | Notes | | --- | --- | --- | --- | | `glaze` (default) | Glaze credits | none | Always the default and the fallback | | `gemini` | free | paste a free AI Studio key | ~250 calls/day free tier; recommended free option | | `openrouter` | free | paste an OpenRouter key | ~50 calls/day unfunded; `openrouter/free` auto-routes; optional third choice | | `claude` | free with a Claude subscription | Claude Code installed + logged in | For users known to have Claude Code; settings-only, slower (seconds to a minute per call) |
Rules that keep this correct and honest:
Glaze AI, never break the feature.
since Glaze remains default + fallback. Publish rejects AI apps without it.
renderer. Only boolean `hasKey` flags cross IPC.
`https://openrouter.ai/settings/keys`. Open via `shell.openExternal`. Automatic key provisioning is not possible; a deep link plus paste field is the simplest flow.
only when clicked. Never run it (or any AI call) yourself during verification; verify with type-check and build only.
own consent UI explains credits.
collect Anthropic API keys, OAuth tokens, or Claude credential files for it, and never persist `CLAUDE_CODE_OAUTH_TOKEN`. Offer it to audiences known to have Claude Code; keep it in full settings, not onboarding. Detection gates the UI state (a found/not-found badge), and a missing CLI falls back to Glaze like a missing key.
From the app's `.glaze-sources/` (bundled Node on PATH, managed npmrc):
npm install --include=dev @ai-sdk/google @ai-sdk/openai-compatible
Both are pure JS and bundle cleanly. The SDK's bundled `ai` package accepts third-party provider models (it upgrades provider spec v2/v3 internally), so these plug straight into the `generateObject`/`generateText` re-exported by `@glaze/core/ai`.
Adapt storage to the app: if it already has a JSON store helper, reuse it; otherwise keep the inline `readJson`/`writeJson` below. Everything else drops in as is.
// AI engine selection: "glaze" (built-in, credits) | "gemini" | "openrouter" (BYOK).
// Keys are safeStorage-encrypted and never leave the backend.
import { generateText, glaze, type LanguageModel } from "@glaze/core/ai";
import { app, logger, safeStorage } from "@glaze/core/backend";
import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import fs from "fs/promises";
import path from "path";
export type AIProviderId = "glaze" | "gemini" | "openrouter";
export interface AISettings { provider: AIProviderId; openrouterModel: string; }
export interface AISettingsView extends AISettings { hasGeminiKey: boolean; hasOpenrouterKey: boolean; }
export const GEMINI_MODEL = "gemini-2.5-flash";
export const DEFAULT_OPENROUTER_MODEL = "openrouter/free";
const DEFAULTS: AISettings = { provider: "glaze", openrouterModel: DEFAULT_OPENROUTER_MODEL };
async function fileIn(name: string): Promise<string> {
const dir = app.getPath("userData");
await fs.mkdir(dir, { recursive: true });
return path.join(dir, name);
}
async function readJson<T>(name: string, fallback: T): Promise<T> {
try { return JSON.parse(await fs.readFile(await fileIn(name), "utf-8")) as T; }
catch { return fallback; }
}
async function writeJson(name: string, value: unknown): Promise<void> {
await fs.writeFile(await fileIn(name), JSON.stringify(value, null, 2), "utf-8");
}
const SETTINGS_FILE = "ai-settings.json";
const KEYS_FILE = "ai-keys.json"; // base64 of safeStorage-encrypted buffers
export async function getAISettiBuild Glaze (by Raycast) desktop apps from Claude Code, using your own Claude subscription instead of Glaze's paid credits. Glaze builds Mac apps with a built-in AI agent, and that agent is what spends Glaze credits.
Build, edit, run, and debug Glaze (Raycast) desktop apps directly from Claude Code, for free, using your own Claude subscription instead of Glaze's paid…