---
name: init-sprite
description: Use this skill when the user wants to create, initialize, or set up a new sprite. This handles creating the sprite, copying Claude Code and Codex auth credentials, updating both tools to latest versions, and verifying they work.
---

Gist: https://gist.github.com/sunxd3/b2ddf15292ef876619a8e25c7f8352e6

You are the sprite initialization agent. When invoked, perform these steps:

## 1. Create the sprite
```bash
sprite api /v1/sprites -X POST -H "Content-Type: application/json" -d '{"name":"<sprite-name>"}'
```
If the user didn't provide a name, ask for one.

## 2. Copy auth credentials from current sprite
Three files must be copied:

```bash
# Create directories
sprite exec -s <sprite-name> mkdir -p /home/sprite/.claude /home/sprite/.codex

# Claude Code OAuth tokens
cat ~/.claude/.credentials.json | sprite exec -s <sprite-name> sh -c 'cat > /home/sprite/.claude/.credentials.json && chmod 600 /home/sprite/.claude/.credentials.json'

# Claude Code user account info
cat ~/.claude.json | sprite exec -s <sprite-name> sh -c 'cat > /home/sprite/.claude.json && chmod 600 /home/sprite/.claude.json'

# Codex OAuth tokens
cat ~/.codex/auth.json | sprite exec -s <sprite-name> sh -c 'cat > /home/sprite/.codex/auth.json && chmod 600 /home/sprite/.codex/auth.json'
```

## 3. Copy config files from current sprite
```bash
# Claude Code settings
cat ~/.claude/settings.json | sprite exec -s <sprite-name> sh -c 'cat > /home/sprite/.claude/settings.json && chmod 600 /home/sprite/.claude/settings.json'

# Codex config
cat ~/.codex/config.toml | sprite exec -s <sprite-name> sh -c 'cat > /home/sprite/.codex/config.toml && chmod 600 /home/sprite/.codex/config.toml'
```

## 4. Copy GitHub CLI auth
```bash
# Copy gh config
sprite exec -s <sprite-name> mkdir -p /home/sprite/.config/gh
cat ~/.config/gh/hosts.yml | sprite exec -s <sprite-name> sh -c 'cat > /home/sprite/.config/gh/hosts.yml && chmod 600 /home/sprite/.config/gh/hosts.yml'
```

## 5. Copy skill files and dotfiles

```bash
# Copy codex skill for Claude Code
sprite exec -s <sprite-name> mkdir -p /home/sprite/.claude/skills/codex
cat ~/.claude/skills/codex/SKILL.md | sprite exec -s <sprite-name> sh -c 'cat > /home/sprite/.claude/skills/codex/SKILL.md'

# Copy tmux config
cat ~/.tmux.conf | sprite exec -s <sprite-name> sh -c 'cat > /home/sprite/.tmux.conf'
```

## 6. Install additional tools

```bash
# Install uv (Python package manager)
sprite exec -s <sprite-name> sh -c 'curl -LsSf https://astral.sh/uv/install.sh | sh'

# Install Julia via juliaup
sprite exec -s <sprite-name> sh -c 'curl -fsSL https://install.julialang.org | sh -s -- --yes'
```

## 7. Update tools to latest versions
```bash
sprite exec -s <sprite-name> sh -c 'claude update'
sprite exec -s <sprite-name> sh -c 'npm install -g @openai/codex --prefix /home/sprite/.local'
```

## 8. Verify auth works
```bash
# Test Claude Code
sprite exec -s <sprite-name> sh -c 'echo "Say hello in one sentence" | claude --print'

# Test Codex
sprite exec -s <sprite-name> sh -c 'codex exec --skip-git-repo-check "Say hello in one sentence"'
```

## 9. Report results
Summarize what was created, updated, and whether both tools authenticated successfully.

## Troubleshooting

### Sprite stuck in "starting" status
If a sprite gets stuck in "starting" and `sprite exec` hangs, wake it via the API:
```bash
sprite api /v1/sprites/<sprite-name>/exec?cmd=whoami -X POST
```
Or try a filesystem read:
```bash
sprite api /v1/sprites/<sprite-name>/fs/list?path=/home/sprite
```
There is no explicit "start" command — sprites boot on demand when you make an API call that requires the sprite to be alive. Hitting the sprite's public URL does NOT work (intercepted by auth gate).
