SnapAI

repository·main·Indexed 23 days ago

https://github.com/betomoedano/snapai

An AI-powered CLI tool for mobile app developers (React Native and Expo) to generate high-quality 1024x1024 app icons and 1024x500 Google Play feature graphics. It integrates with OpenAI and Google Gemini models, offering features like prompt enhancement, logo compositing, and support for various output formats including PNG, JPEG, and WebP.

Tokens
11.1K
Snippets
32
Records
59
Agent score
82%

What's inside snapai

  1. Understand SnapAI credential precedence

    main

    SnapAI resolves credentials in a specific order. Higher priority items override lower priority ones.

    OpenAI Priority Order:

    1. --openai-api-key (CLI flag)
    2. SNAPAI_API_KEY (Env var)
    3. OPENAI_API_KEY (Env var)
    4. Local config (~/.snapai/config.json)

    Google Priority Order:

    1. --google-api-key (CLI flag)
    2. SNAPAI_GOOGLE_API_KEY (Env var)
    3. GEMINI_API_KEY (Env var)
    4. Local config (~/.snapai/config.json)
  2. Control prompt enhancement and styles

    main

    SnapAI automatically expands prompts to improve results. You can control this behavior:

    • Styles: Use --style <preset> to apply a visual theme. Built-in styles include: minimalism, glassy, woven, geometric, neon, gradient, flat, material, ios-classic, android-material, pixel, game, clay, holographic, kawaii, and cute.
    • --use-icon-words: Forces the inclusion of terms like "icon" or "logo" in the expanded prompt (useful if the enhancer is being too abstract).
    • --raw-prompt: Disables automatic enhancement. The --style flag will still be applied as a dominant constraint.
    • --prompt-only: A preview mode. It prints the final enhanced prompt and resolved configuration to the console without calling the image provider (saves credits).
    # Preview the enhanced prompt without generating an image
    npx snapai icon \
      --prompt "calculator app" \
      --style minimalism \
      --prompt-only
    
    # Use a raw prompt without enhancement
    npx snapai icon \
      --prompt "a single red circle centered on a cream background" \
      --raw-prompt
  3. Use Development Mode with Hot Reload

    main

    SnapAI supports a hot-reload development workflow where changes to TypeScript files are automatically recompiled and reflected in the CLI execution.

    1. Terminal 1: Start the TypeScript compiler in watch mode using snapai-watch or pnpm run dev.
    2. Terminal 2: Run commands using the development wrapper snapai-dev to test changes immediately.

    Example commands for testing:

    • snapai-dev icon --prompt "test icon"
    • snapai-dev config --show

    Alternatively, you can use the local script directly: ./dev-cli.js icon --prompt "test icon"

    # Terminal 1
    snapai-watch
    
    # Terminal 2
    snapai-dev icon --prompt "test icon"
  4. Use SnapAI in GitHub Actions

    main

    To use SnapAI in a GitHub Action, store your API key as a repository secret and expose it as an environment variable in the specific step that requires it.

    - name: Generate app icon
      run: >
        npx snapai icon
        --prompt "minimalist weather app with sun and cloud"
        --output ./assets/icons
      env:
        SNAPAI_API_KEY: ${{ secrets.SNAPAI_API_KEY }}
  5. Test SnapAI locally before publishing

    main

    Before publishing to npm, verify the build and package contents locally using these commands:

    • Build and test: pnpm run build
    • Run development binary: ./bin/dev.js --help or ./bin/dev.js config --show
    • Full production build: pnpm run prepare-publish followed by node bundle/snapai.js --help
    • Preview package contents: npm pack --dry-run
    pnpm run build
    ./bin/dev.js --help
    ./bin/dev.js config --show
    
    pnpm run prepare-publish
    node bundle/snapai.js --help
    
    npm pack --dry-run
  6. Configure SnapAI locally

    main

    To store API keys permanently on your machine, use the snapai config command. This saves credentials to ~/.snapai/config.json. Use --show to view your current configuration; note that API keys will be masked for security.

    To save an OpenAI key:

    snapai config --openai-api-key "sk-your-openai-api-key"

    To save a Google AI Studio key:

    snapai config --google-api-key "your-google-ai-studio-key"
    snapai config --openai-api-key "sk-your-openai-api-key"
    snapai config --google-api-key "your-google-ai-studio-key"
    snapai config --show
  7. Install and use SnapAI

    main

    SnapAI allows you to generate app icon artwork (1024x1024) and Google Play feature graphics (1024x500) using OpenAI or Google Gemini via the CLI.

    Prerequisites:

    • Node.js 18 or newer
    • An API key from OpenAI or Google AI Studio

    Installation Options:

    • Run without installing: Use npx snapai.
    • Global installation: npm install -g snapai.

    Quick Start Commands:

    • View all commands: npx snapai --help
    • Save an OpenAI key: npx snapai config --openai-api-key "sk-your-openai-api-key"
    • Generate an icon: npx snapai icon --prompt "your prompt here"

    By default, images are saved to the ./assets directory.

    npx snapai icon --prompt "minimalist weather app with sun and cloud"
  8. Use SnapAI with an AI agent for Expo projects

    main

    For Expo projects, you can use the Code with Beto App Icon skill to automate the entire workflow: generating artwork, preparing iOS .icon folders and Android adaptive icon assets, and updating Expo configuration.

    Using skills CLI

    Install the skill via the skills CLI:

    npx skills add https://github.com/code-with-beto/skills --skill app-icon

    Using Codex

    1. Add the marketplace: codex plugin marketplace add Code-with-Beto/skills
    2. Run /plugins and install the App Icon plugin from the Code with Beto marketplace.

    Using Claude Code

    Run these commands inside Claude Code:

    /plugin marketplace add Code-with-Beto/skills
    /plugin install cwb-app-icon@cwb-plugins
  9. Use SnapAI with an AI Agent

    main

    For the easiest workflow, you can use the Code with Beto App Icon skill with compatible agents like Codex or Claude Code. This skill automates the generation of artwork and the configuration of Expo app.json files.

    Setup:

    npx skills add https://github.com/code-with-beto/skills --skill app-icon

    Usage: Once installed, describe your requirement in natural language to the agent:

    Create an app icon for my Expo app. It is a habit tracker that feels calm, friendly, and modern. Generate the icon assets and configure app.json for iOS and Android.
    npx skills add https://github.com/code-with-beto/skills --skill app-icon
  10. Promote a beta version to stable

    main

    To promote a tested beta version to the stable latest release:

    1. Bump to the stable version: Use npm version minor (or the appropriate bump) to remove the pre-release suffix.
    2. Push and Tag: git push && git push --tags.
    3. Create a GitHub Release: Create a new release using the new stable tag, ensuring the "Set as a pre-release" box is unchecked.
    # Example: 1.2.0-beta.3 -> 1.2.0
    npm version minor
    git push && git push --tags
  11. Set up the SnapAI development environment

    main

    To develop on SnapAI, perform an initial setup by installing dependencies and building the project. For an optimized workflow, it is recommended to set up shell aliases to manage watch modes and development wrappers.

    Initial Setup

    1. Navigate to the project directory.
    2. Install dependencies using pnpm install.
    3. Build the project using pnpm run build.

    Add these to your shell profile (e.g., ~/.zshrc or ~/.bashrc) to simplify development tasks:

    alias snapai-watch="cd /Users/beto/Desktop/apps/snapai && pnpm run dev"
    alias snapai-dev="cd /Users/beto/Desktop/apps/snapai && ./bin/dev.js"
    alias snapai-build="cd /Users/beto/Desktop/apps/snapai && pnpm run build && node dist/index.js"

    After adding, reload your shell with source ~/.zshrc (or your respective config file).

    cd /Users/beto/Desktop/apps/snapai
    pnpm install
    pnpm run build