# GLM Usage Guidelines

## When to Use GLM (Default)

Use GLM for these scenarios:
- **Simple to medium complexity** tasks
- **Clear, well-defined requirements**
- **Rapid prototyping** and experimentation
- Standard CRUD operations
- Utility functions and helpers
- Data transformations
- API integrations (standard patterns)
- File operations
- String/data parsing

**Characteristics of GLM-appropriate tasks**:
- Single responsibility functions
- No complex recursion
- No deeply nested logic
- Standard design patterns
- Well-established algorithms

## ❌ When NOT to Use GLM (Use Claude Instead)

**NEVER use GLM for**:
- Debugging existing code
- Fixing syntax errors or runtime errors
- Refactoring complex legacy code
- Production-critical systems

**Prefer Claude for**:
- Complex logic with recursion
- Deeply nested data structures
- Custom algorithms requiring edge case handling
- State machines or complex state management
- Parsers or compilers
- Complex validation logic
- Tasks requiring 100% reliability

## ⚠️ Complexity Assessment

**Before using GLM, assess complexity**:

**Simple (Use GLM)** ✅:
- Single function, clear purpose
- No recursion
- Standard library usage
- < 50 lines of code expected

**Medium (Use GLM)** ✅:
- 2-5 related functions
- Simple class with methods
- Standard design patterns
- < 200 lines of code expected

**Complex (Use Claude)** ⚠️:
- Recursive algorithms
- Multiple nested levels
- Custom data structures
- Complex error handling
- > 500 lines of code expected

**If unsure, use Claude for safety** ✓

## Warning Protocol for Complex Tasks

If you assess a task as potentially complex but GLM is requested:

1. **Show warning to user**:
   ```
   ⚠️ Warning: This task appears complex with [reason].
   GLM may generate code with errors for complex tasks.

   Recommendation: Use Claude for reliability.

   Continue with GLM? (y/n)
   ```

2. **Wait for user confirmation**

3. **If user confirms**: Proceed with GLM but note the risk

4. **If user declines**: Use Claude directly

## GLM Usage Pattern

**Correct workflow:**
```
User: "Create a Python function to validate emails"
Assistant:
1. Assess: Simple task (single function, standard regex)
2. Call: glm "create a function to validate email addresses using regex" --language python
3. Save output to file
4. Show user the result
```

**Incorrect workflow:**
```
User: "Create a Python function to validate emails"
Assistant: Here's the code... [writes code directly] ❌ WRONG
```

**CRITICAL: Always request CODE, not explanations:**
- ✅ GOOD: glm "write a function to parse JSON" --language python
- ✅ GOOD: glm "create a class for user authentication" --language python
- ✅ GOOD: glm "implement binary search algorithm" --language python
- ❌ BAD: glm "tell me how to parse JSON"
- ❌ BAD: glm "explain authentication"
- ❌ BAD: glm "how does binary search work"

**When user asks a question (not code):**
- Answer the question yourself (Claude)
- Do NOT use GLM for non-code tasks
- GLM is for CODE GENERATION ONLY

## Updated Workflow

### Before: Always GLM
```
User: "Create a JSON parser"
Assistant: Uses GLM (may fail if complex)
```

### After: Complexity Assessment
```
User: "Create a JSON parser"
Assistant:
1. Assess: JSON parser = complex (parsing, nested structures)
2. Warn: "⚠️ This is complex, GLM may fail. Use Claude?"
3. User confirms: Use Claude
4. Result: Reliable, working code
```

## Exceptions - User Override Commands

These override the default behavior:

1. **"Claude가 직접 작성해"** or **"you write it directly"**
   - Skip GLM, use Claude

2. **"GLM으로 작성해"** or **"use GLM"**
   - Force GLM usage (but still warn if complex)

3. **"GLM으로 문서를 작성해"** or **"use GLM for documentation"**
   - Use GLM for non-code tasks

**Priority**: User explicit instruction > Complexity assessment > Default rules
