GLM AI subagent plugin for Claude Code - Opus orchestration with multiple GLM workers
npm install claude-glm-agentGLM AI subagent plugin for Claude Code - Opus orchestration with multiple GLM workers.
This plugin enables hybrid AI workflows by allowing Claude (Opus) to delegate tasks to GLM models via the Z.AI API. Use a single GLM call for quick questions, or orchestrate multiple GLM agents in parallel for complex analysis.
- /glm - Ask GLM a single question, get a different perspective from Opus
- /task-with-glm - Opus orchestrates multiple GLM workers in parallel for complex tasks
- Two GLM models: glm-4.7 (best quality) and glm-4.5-air (fast response)
- Automatic command registration - Commands available immediately after installation
``bash1. Install CLI
npm install -g claude-glm-agent
Alternative Installation Methods
curl (No npm required)
`bash
curl -fsSL https://raw.githubusercontent.com/sungmanch/claude-glm-agent/main/scripts/install.sh | bash
export GLM_API_KEY="your-api-key"
`
From Source
`bash
git clone https://github.com/sungmanch/claude-glm-agent.git
cd claude-glm-agent
npm install && npm run build && npm link
claude-glm-agent install
export GLM_API_KEY="your-api-key"
`Usage
$3
Use when you need a different perspective or want to cross-check Opus's response:
`
/glm What are the security implications of this code?
``
/glm Summarize the key points of this discussion
`$3
The
/task-with-glm command automatically detects your task type and applies optimized worker strategies:#### Automatic Scenario Detection
| Scenario | Triggers | Workers |
|----------|----------|---------|
| Bug Fixing | error, bug, fix, crash, broken | Analyzer → Implementers + Validator |
| Code Review | review, PR, evaluate, quality | Quality + Security + Performance + Test Analyzers |
| New Feature | add, implement, create, build | Architect → Implementers → Validator |
| Refactoring | refactor, clean up, restructure | Minimal + Ideal + Migration Architects |
| Exploration | understand, how does, architecture | Scout + Architecture + DataFlow Analyzers |
| Performance | slow, optimize, memory, bottleneck | Time + Memory + I/O + Caching Analyzers |
| Testing | test, coverage, edge case, TDD | Unit + Edge Case + Integration workers |
| Documentation | document, README, API docs | Analyzer → API Documenter → Usage Documenter |
| Planning/Debate | plan, decide, compare, trade-off, which approach | Sonnet + GLM Multi-Model Debate |
#### Example Usage
Bug Fixing:
`
/task-with-glm fix this error: TypeError: Cannot read property 'map' of undefined
`Code Review:
`
/task-with-glm review this PR for security and performance issues
`New Feature:
`
/task-with-glm implement user authentication with JWT tokens
`Refactoring:
`
/task-with-glm refactor this function to be more maintainable
`Exploration:
`
/task-with-glm explain how the authentication system works in this codebase
`Performance:
`
/task-with-glm optimize this slow database query
`Testing:
`
/task-with-glm generate comprehensive tests for the payment module
`Documentation:
`
/task-with-glm document the API endpoints in this controller
`Planning/Debate (Multi-Model):
`
/task-with-glm should we use REST or GraphQL for the new API?
``
/task-with-glm compare Redux vs Zustand for state management in this project
`#### GLM Worker Roles
| Role | Purpose | Model |
|------|---------|-------|
| GLM-Scout | Fast file/pattern discovery | glm-4.5-air |
| GLM-Analyzer | Deep code analysis | glm-4.7 |
| GLM-Architect | Design and architecture | glm-4.7 |
| GLM-Implementer | Implementation proposals | glm-4.7 |
| GLM-Validator | Edge cases, risk assessment | glm-4.5-air |
| GLM-Documenter | Documentation generation | glm-4.5-air |
| Sonnet-Debater | Advocate perspective A in debates | claude-sonnet |
| GLM-Debater | Advocate perspective B in debates | glm-4.7 |
Architecture
`
┌─────────────────────────────────────────────────────────────┐
│ Opus (Orchestrator) │
│ ┌─────────────┬─────────────┬─────────────┬─────────────┐ │
│ │ GLM Agent 1 │ GLM Agent 2 │ GLM Agent 3 │ GLM Agent N │ │
│ │ (Task A) │ (Task B) │ (Task C) │ (...) │ │
│ └─────────────┴─────────────┴─────────────┴─────────────┘ │
└─────────────────────────────────────────────────────────────┘
`With
/task-with-glm, Opus:
1. Detects scenario from keywords (bug, review, feature, refactor, etc.)
2. Assigns specialized roles (Scout, Analyzer, Architect, Implementer, Validator, Documenter)
3. Executes workers in parallel or sequential phases based on scenario
4. Synthesizes results with scenario-specific templates
5. Validates consistency, confidence levels, and follow-up needsAvailable Models
| Model | Use Case |
|-------|----------|
|
glm-4.7 | Complex analysis, code review, detailed responses (default) |
| glm-4.5-air | Quick questions, summaries, simple tasks |CLI Commands
`bash
Install (or reinstall) the plugin
claude-glm-agent installForce reinstall (overwrite existing files)
claude-glm-agent install --forceUninstall
claude-glm-agent uninstallShow help
claude-glm-agent --helpShow version
claude-glm-agent --version
`File Locations
After installation, files are placed in:
`
~/.claude/
├── agents/
│ ├── glm-worker.md # GLM worker agent definition
│ ├── debate-sonnet.md # Sonnet debater for multi-model debates
│ └── debate-glm.md # GLM debater for multi-model debates
├── commands/
│ ├── glm.md # /glm command
│ └── task-with-glm.md # /task-with-glm command
└── plugins/local/claude-glm-agent/
├── scripts/
│ ├── glm_call.py # GLM API caller (Python)
│ ├── glm_call.mjs # GLM API caller (Node.js)
│ └── glm_call.sh # GLM API caller (Shell wrapper)
└── metadata.json # Installation metadata
`Troubleshooting
$3
Ensure you've set the API key:
`bash
export GLM_API_KEY="your-api-key"
`$3
1. Restart Claude Code after installation
2. Check that files exist:
ls -la ~/.claude/commands/
3. Try reinstalling with --force: claude-glm-agent install --force`The default timeout is 180 seconds. For very long requests, consider breaking them into smaller subtasks.
This project was inspired by and references the following projects:
- oh-my-claudecode by Yeachan Heo - Multi-agent orchestration for Claude Code with 28 agents and delegation-first architecture
- oh-my-opencode by Yeongyu Kim - The original Sisyphus agent harness for OpenCode with multi-model orchestration
- llm-council by Andrej Karpathy - Multi-LLM deliberation system where models review and synthesize each other's work
MIT
Sungman Cho