---
name: eeCode
description: Offload grunt work to local Qwen 32B model - zero cost, parallel execution
user-invocable: true
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
---

# Embrava Edge Code - Local LLM Offloading

Offload mechanical coding tasks to the local Qwen2.5-Coder-32B-Instruct-AWQ model running on this device.

**Cost:** $0 (local inference)
**Concurrency:** Up to 25 parallel requests
**Speed:** ~44 seconds per file average

## When This Skill is Invoked

Analyze the user's request and determine which parts can be offloaded to the local Qwen model.

### Offload to Qwen (DO THIS)

| Task Type | Examples |
|-----------|----------|
| **Refactoring** | Rename variables, extract functions, restructure code |
| **Pattern Migration** | Convert class→hooks, callbacks→async/await, any A→B transform |
| **Bulk Transformations** | Apply same change across multiple files |
| **Boilerplate Generation** | New components/modules following existing patterns |
| **Type Additions** | Add TypeScript types, Python type hints, Zod schemas |
| **Documentation** | Generate docstrings, JSDoc, README sections, inline comments |
| **Test Generation** | Unit tests, integration tests for existing functions |
| **Code Translation** | Port between frameworks/languages |
| **Formatting/Style** | Consistent code style, linting fixes |
| **Simple Bug Fixes** | Obvious errors with clear fix patterns |
| **Data Transformations** | JSON reshaping, SQL generation, schema conversions |
| **Regex/String Work** | Complex regex patterns, string manipulation |
| **API Client Generation** | Generate typed clients from OpenAPI/schemas |
| **Migration Scripts** | Database migrations, data transformations |
| **Config Generation** | Generate configs from templates |

### Keep for Claude (DON'T offload)

- Architecture decisions requiring system-wide understanding
- Complex debugging with subtle state issues
- Security review and vulnerability analysis
- Clarifying ambiguous user requirements
- Novel implementations without existing patterns
- Cross-file reasoning about component interactions
- API design decisions (naming, ergonomics)

## Execution Protocol

### Step 1: Analyze the Task

Break down the request into discrete units of work. Identify which are mechanical (offload) vs architectural (keep).

### Step 2: Prepare Batch Operations

For each file/task to offload:
1. Read the source file
2. Formulate clear, explicit instructions for Qwen
3. Include relevant context (types, interfaces, examples)

### Step 3: Execute in Parallel

**Single file:**
```bash
python3 .claude/skills/refactor/refactor.py "<file_path>" "<instructions>"
```

**Multiple files (parallel):**
```bash
# Run up to 25 concurrent operations
python3 .claude/skills/refactor/refactor.py "file1.tsx" "instructions" &
python3 .claude/skills/refactor/refactor.py "file2.tsx" "instructions" &
python3 .claude/skills/refactor/refactor.py "file3.tsx" "instructions" &
wait
```

**Direct API (for custom prompts):**
```bash
curl -sk ${EECODE_API_URL:-https://localhost:8443/v1}/chat/completions \
  -H "Authorization: Bearer $EECODE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen2.5-Coder-32B-Instruct-AWQ",
    "messages": [
      {"role": "system", "content": "You are an expert programmer. Return ONLY code, no explanations or markdown fences."},
      {"role": "user", "content": "YOUR TASK HERE"}
    ],
    "temperature": 0.3,
    "max_tokens": 8192
  }'
```

### Step 4: Review & Apply

1. Check Qwen's output for correctness
2. Apply changes using Write/Edit tools
3. If Qwen fails on a task, either retry with clearer instructions or handle it directly

## Prompt Engineering for Qwen

The 32B model responds well to:

- **Explicit instructions**: "Convert all useState hooks to useReducer"
- **Examples**: "Follow this pattern: [example code]"
- **Constraints**: "Keep the same function signatures"
- **Context**: Include relevant types/interfaces the code depends on

**Good prompt:**
```
Convert this React class component to a functional component with hooks.
Keep all prop types. Use useState for state, useEffect for lifecycle.
Preserve all existing functionality.

[code here]
```

**Bad prompt:**
```
Make this better
[code here]
```

## Example Workflows

### Bulk Type Addition
```
User: "Add TypeScript types to all files in src/utils/"

1. Glob for src/utils/*.ts
2. For each file, call Qwen: "Add comprehensive TypeScript types to all functions and variables. Infer types from usage. Export interfaces for complex types."
3. Run in parallel (up to 25)
4. Review and commit
```

### Pattern Migration
```
User: "Convert all class components to hooks"

1. Grep for "extends React.Component" or "extends Component"
2. For each file, call Qwen: "Convert this class component to a functional component using hooks. useState for state, useEffect for componentDidMount/componentDidUpdate/componentWillUnmount. Keep the same props interface."
3. Run in parallel
4. Review and commit
```

### Test Generation
```
User: "Write tests for the auth module"

1. Read src/auth/*.ts to understand the functions
2. For each file, call Qwen: "Write Jest unit tests for these functions. Cover happy path, edge cases, and error conditions. Use describe/it blocks. Mock external dependencies."
3. Write test files
4. Run tests to verify
```

## API Configuration

Configure via environment variables in your shell profile (`~/.bashrc`, `~/.zshrc`):

```bash
export EECODE_API_KEY="sk-edge-your-key-here"
export EECODE_API_URL="https://your-edge-device:8443/v1"  # optional
export EECODE_MODEL="Qwen/Qwen2.5-Coder-32B-Instruct-AWQ"  # optional
```

| Variable | Default | Description |
|----------|---------|-------------|
| `EECODE_API_KEY` | (required) | Your Embrava Edge API key |
| `EECODE_API_URL` | `https://localhost:8443/v1` | API endpoint |
| `EECODE_MODEL` | `Qwen/Qwen2.5-Coder-32B-Instruct-AWQ` | Model ID |
| `EECODE_MAX_TOKENS` | `8192` | Max generation length |
| `EECODE_TIMEOUT` | `300` | Request timeout (seconds) |

## Error Handling

If Qwen returns bad output:
1. **Retry with more context** - Include more surrounding code, types, examples
2. **Simplify the task** - Break into smaller chunks
3. **Escalate to Claude** - Some tasks genuinely need stronger reasoning

Common failure modes:
- Missing imports (include them in context)
- Wrong framework assumptions (be explicit: "This is React, not Vue")
- Incomplete output (increase max_tokens or split task)
