# AGENTS.md - Octocode CLI
> **Location**: `packages/octocode-cli/AGENTS.md`
AI agent guidance for the `octocode-cli` package - Interactive CLI installer and management hub for Octocode MCP servers and AI skills.
This file **overrides** the root [`AGENTS.md`](../../AGENTS.md) for work within this package.
---
## Overview
Octocode CLI is the unified installer and management hub for AI-assisted development:
- **MCP Installation**: One-step setup for `octocode-mcp` across multiple IDEs
- **GitHub Authentication**: Secure OAuth flow with encrypted token storage
- **Configuration Sync**: Keep MCP configurations consistent across editors
- **Skills Manager**: Install and update AI coding skills for Claude Code
- **MCP Marketplace**: Browse and install 70+ community MCP servers
**Key Docs**: [`README.md`](./README.md) β’ [Root AGENTS.md](../../AGENTS.md) β’ [`docs/`](./docs/)
### Documentation
| Document | Description |
|----------|-------------|
| [`CLI_REFERENCE.md`](./docs/CLI_REFERENCE.md) | Complete CLI commands reference with options and examples |
| [`MENU_FLOW.md`](./docs/MENU_FLOW.md) | Interactive menu system documentation with flow diagrams |
| [`ARCHITECTURE.md`](./docs/ARCHITECTURE.md) | Technical architecture and design patterns |
| [`SKILLS_GUIDE.md`](./docs/SKILLS_GUIDE.md) | Comprehensive guide to Octocode Skills system |
---
## π οΈ Commands
All commands run from this package directory (`packages/octocode-cli/`).
| Task | Command | Description |
|------|---------|-------------|
| **Build** | `yarn build` | Lint + bundle with Vite |
| **Build (Dev)** | `yarn build:dev` | Build without lint |
| **Clean** | `yarn clean` | Remove `out/` directory |
| **Test** | `yarn test` | Run tests with coverage report |
| **Test (Quiet)** | `yarn test:quiet` | Minimal test output |
| **Test (Watch)** | `yarn test:watch` | Watch mode for tests |
| **Lint** | `yarn lint` | ESLint check |
| **Lint (Fix)** | `yarn lint:fix` | Auto-fix linting issues |
| **Typecheck** | `yarn typecheck` | TypeScript type checking |
| **Start** | `yarn start` | Run the CLI locally |
### Validation Scripts
| Task | Command | Description |
|------|---------|-------------|
| **Validate MCP Registry** | `yarn validate:mcp` | Validate MCP server registry |
| **Validate Skills** | `yarn validate:skills` | Validate skills marketplace |
---
## π Package Structure
```
src/
βββ index.ts # Entry point - CLI initialization
β
βββ cli/ # π₯οΈ Command-line interface
β βββ index.ts # CLI runner & exports
β βββ commands.ts # Command definitions & handlers
β βββ parser.ts # Argument parsing
β βββ help.ts # Help text generation
β βββ types.ts # CLI type definitions
β
βββ configs/ # βοΈ Configuration registries
β βββ mcp-registry.ts # MCP server registry (70+ servers)
β βββ skills-marketplace.ts # AI skills marketplace config
β
βββ features/ # π§ Core feature implementations
β βββ gh-auth.ts # GitHub authentication wrapper
β βββ github-oauth.ts # OAuth device flow implementation
β βββ install.ts # MCP installation logic
β βββ node-check.ts # Node.js environment detection
β βββ sync.ts # Configuration sync across IDEs
β
βββ types/ # π Type definitions
β βββ index.ts # Shared types (IDE configs, MCP types)
β
βββ ui/ # π¨ Interactive UI modules
β βββ menu.ts # Main interactive menu
β βββ header.ts # Welcome banner & branding
β βββ constants.ts # UI constants & styling
β βββ gh-guidance.ts # GitHub auth guidance
β βββ state.ts # UI state management
β β
β βββ config/ # Configuration inspection
β β βββ index.ts # Config flow orchestration
β β βββ inspect-flow.ts # Config inspection UI
β β
β βββ external-mcp/ # MCP marketplace
β β βββ index.ts # Exports
β β βββ flow.ts # Marketplace flow logic
β β βββ display.ts # Server display formatting
β β βββ prompts.ts # Selection prompts
β β
β βββ install/ # Installation wizard
β β βββ index.ts # Exports
β β βββ flow.ts # Installation flow logic
β β βββ display.ts # Progress & status display
β β βββ environment.ts # Environment checks
β β βββ prompts.ts # IDE selection prompts
β β
β βββ skills-menu/ # Skills management
β β βββ index.ts # Skills installation UI
β β βββ marketplace.ts # Skills marketplace display
β β
β βββ sync/ # Sync UI
β βββ index.ts # Exports
β βββ flow.ts # Sync flow logic
β βββ display.ts # Sync status display
β
βββ utils/ # π οΈ Shared utilities
βββ assert.ts # Assertion helpers
βββ colors.ts # Terminal color formatting
βββ context.ts # Runtime context detection
βββ fs.ts # File system utilities
βββ mcp-config.ts # MCP configuration parsing
βββ mcp-io.ts # MCP config file I/O
βββ mcp-paths.ts # IDE-specific config paths
βββ platform.ts # Cross-platform utilities
βββ prompts.ts # Inquirer prompt loading
βββ research-output.ts # Research output handling
βββ shell.ts # Shell command execution
βββ skills.ts # Skills file management
βββ skills-fetch.ts # Skills download & install
βββ spinner.ts # Loading spinner component
βββ token-storage.ts # Encrypted token management (AES-256-GCM)
```
### Skills Directory
```
skills/
βββ README.md # Skills documentation
βββ octocode-implement/ # Implementation skill from specs
β βββ SKILL.md
β βββ references/
β βββ execution-phases.md
β βββ tool-reference.md
β βββ workflow-patterns.md
βββ octocode-local-search/ # Local code exploration skill
β βββ SKILL.md
β βββ references/
β βββ tool-reference.md
β βββ workflow-patterns.md
βββ octocode-plan/ # Adaptive research & implementation planning
β βββ SKILL.md
βββ octocode-pr-review/ # PR review skill
β βββ SKILL.md
β βββ references/
β βββ domain-reviewers.md
β βββ execution-lifecycle.md
β βββ research-flows.md
βββ octocode-research/ # Research skill for code exploration
β βββ SKILL.md
β βββ references/
β βββ tool-reference.md
β βββ workflow-patterns.md
βββ octocode-roast/ # Code roasting skill for fun feedback
βββ SKILL.md
βββ references/
βββ sin-registry.md
```
### Tests Structure
```
tests/
βββ setup.ts # Test setup & configuration
βββ colors.test.ts # Color utility tests
βββ cli/ # CLI module tests
β βββ commands.test.ts # Command handler tests
β βββ parser.test.ts # Argument parser tests
βββ configs/ # Configuration tests
β βββ skills-marketplace.test.ts
βββ features/ # Feature tests
β βββ gh-auth.test.ts # GitHub auth tests
β βββ github-oauth.test.ts # OAuth flow tests
β βββ install.test.ts # Installation tests
β βββ node-check.test.ts # Node detection tests
β βββ sync.test.ts # Sync feature tests
βββ ui/ # UI component tests
β βββ external-mcp-flow.test.ts
βββ utils/ # Utility tests
βββ assert.test.ts
βββ context.test.ts
βββ fs.test.ts
βββ mcp-config.test.ts
βββ mcp-config-coverage.test.ts
βββ mcp-config-extended.test.ts
βββ mcp-io.test.ts
βββ mcp-paths.test.ts
βββ platform.test.ts
βββ prompts.test.ts
βββ research-output.test.ts
βββ shell.test.ts
βββ skills.test.ts
βββ skills-fetch.test.ts
βββ spinner.test.ts
βββ token-storage.test.ts
```
---
## π₯οΈ CLI Commands
| Command | Description | Options |
|---------|-------------|---------|
| `install` | Install octocode-mcp for an IDE | `--ide`, `--method` |
| `login` | Authenticate with GitHub | `--hostname` (enterprise) |
| `status` | Check authentication status | - |
| `sync` | Sync MCP configs across IDEs | `--dry-run` |
| `skills list` | List available AI skills | - |
| `skills install` | Install AI skills | - |
---
## π¨ Supported IDEs
| IDE | Config Location (macOS) | Key |
|-----|-------------------------|-----|
| Cursor | `~/.cursor/mcp.json` | `cursor` |
| Claude Desktop | `~/Library/Application Support/Claude/` | `claude-desktop` |
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | `windsurf` |
| Zed | `~/.config/zed/settings.json` | `zed` |
| Claude Code | `~/.claude.json` | `claude-code` |
| VS Code (Cline) | Extension settings | `cline` |
| VS Code (Roo-Cline) | Extension settings | `roo-cline` |
| VS Code (Continue) | Extension settings | `vscode-continue` |
| Trae | TBD | `trae` |
| Antigravity | TBD | `antigravity` |
---
## π¦ Package Guidelines
These are the core principles for this CLI package:
1. **User Experience First**: Interactive wizards guide users through complex setups.
2. **Cross-Platform**: Support macOS, Linux, and Windows with platform-specific paths.
3. **Secure Storage**: Token encryption (AES-256-GCM) with keytar for credential management.
4. **Graceful Degradation**: Handle missing dependencies and network errors gracefully.
5. **Minimal Dependencies**: Keep the bundle size small for `npx` usage.
---
## ποΈ Architecture Patterns
### Entry Point Flow
```
main() β initializeSecureStorage() β runCLI() β [command handler] OR runInteractiveMode()
```
1. **Secure Storage Init** (`token-storage.ts`) - Initialize encrypted storage
2. **CLI Check** (`cli/index.ts`) - Parse args, execute command if provided
3. **Interactive Mode** (`ui/menu.ts`) - Launch interactive menu if no command
### Key Design Decisions
- **Inquirer Prompts**: Dynamic loading for faster startup
- **Token Security**: AES-256-GCM encryption with platform file storage integration
- **MCP Registry**: Centralized registry of 70+ validated MCP servers
- **Skills System**: Markdown-based skill definitions for Claude Code
---
## π‘οΈ Safety & Permissions
### Package-Level Access
| Path | Access | Description |
|------|--------|-------------|
| `src/` | β
FULL | Source code |
| `tests/` | β
FULL | Test files |
| `skills/` | β
EDIT | Skill definitions |
| `scripts/` | β οΈ ASK | Validation scripts |
| `*.json`, `*.config.*` | β οΈ ASK | Package configs |
| `out/`, `node_modules/` | β NEVER | Generated files |
### Protected Files
- **Never Modify**: `out/`, `node_modules/`
- **Ask Before Modifying**: `package.json`, `tsconfig.json`, `vitest.config.ts`, `vite.config.ts`
### Security Considerations
- **Token Storage**: Tokens are encrypted and stored in `~/.octocode/` with platform file storage backup
- **OAuth Flow**: Uses GitHub's device authorization flow for secure authentication
- **No Credential Logging**: Never log tokens or sensitive data
---
## π§ͺ Testing Protocol
### Requirements
- **Coverage**: 90% required (Statements, Branches, Functions, Lines)
- **Framework**: Vitest with v8 coverage
### Test Categories
| Category | Path | Purpose |
|----------|------|---------|
| Unit | `tests/<module>.test.ts` | Individual function tests |
| CLI | `tests/cli/` | Command parsing & execution |
| Features | `tests/features/` | Feature implementation tests |
| UI | `tests/ui/` | Interactive flow tests |
| Utils | `tests/utils/` | Utility function tests |
| Configs | `tests/configs/` | Configuration validation |
### Testing Notes
- **Mock External Services**: Mock GitHub API, file system, and file storage operations
- **Platform Tests**: Test cross-platform path resolution
- **Interactive Tests**: Use mock prompts for interactive UI testing
---
## π€ Development Tips
### Adding a New CLI Command
1. Add command definition in `src/cli/commands.ts`
2. Implement handler function
3. Add help text in `src/cli/help.ts`
4. Write tests in `tests/cli/commands.test.ts`
### Adding a New MCP Server to Registry
1. Edit `src/configs/mcp-registry.ts`
2. Add server entry with name, description, command, and args
3. Run `yarn validate:mcp` to verify
### Adding a New IDE Support
1. Add IDE config in `src/types/index.ts`
2. Add path resolution in `src/utils/mcp-paths.ts`
3. Add installation logic in `src/ui/install/`
4. Write tests for the new IDE
### Adding a New Skill
1. Create directory in `skills/<skill-name>/`
2. Add `SKILL.md` with skill definition
3. Update `src/configs/skills-marketplace.ts`
4. Run `yarn validate:skills` to verify
---
## π― Skills System
Skills are markdown-based instruction sets that teach AI assistants how to perform specific tasks. They transform generic AI assistants into specialized experts.
### Official Skills
| Skill | Description | Flow |
|-------|-------------|------|
| `octocode-research` | Evidence-first code forensics (external GitHub) | PREPARE β DISCOVER β ANALYZE β OUTPUT |
| `octocode-local-search` | Local-first code exploration and discovery | DISCOVER β PLAN β EXECUTE β VERIFY β OUTPUT |
| `octocode-implement` | Research-driven feature implementation from specs | SPEC β CONTEXT β PLAN β RESEARCH β IMPLEMENT β VALIDATE |
| `octocode-plan` | Adaptive research & implementation planning | UNDERSTAND β RESEARCH β PLAN β IMPLEMENT β VERIFY |
| `octocode-pr-review` | Defects-first PR review across 6+ domains | CONTEXT β CHECKPOINT β ANALYSIS β FINALIZE β REPORT |
| `octocode-roast` | Brutally honest code review with comedic flair | SCOPE β ROAST β INVENTORY β SPOTLIGHT β REDEMPTION |
### Skill Structure
```
{skill-name}/
βββ SKILL.md # Main reference (<500 lines)
βββ references/ # Supporting documentation (optional)
βββ tool-reference.md
βββ workflow-patterns.md
```
### SKILL.md Format
Skills use YAML frontmatter for metadata:
```yaml
---
name: skill-name
description: Use when [specific triggers]...
---
# Skill Title
## Flow Overview
`PHASE1` β `PHASE2` β `PHASE3`
## 1. Agent Identity
<agent_identity>
Role: **Agent Type**. Expert description.
**Objective**: What the agent does.
**Principles**: Core behaviors.
</agent_identity>
## 2. Scope & Tooling
<tools>
| Tool | Purpose |
|------|---------|
| `toolName` | When to use |
</tools>
```
### Skills Marketplace
The CLI includes a skills marketplace with 8+ community sources:
| Marketplace | Description |
|-------------|-------------|
| π Octocode Official | Research, planning, review & roast skills |
| Build With Claude | Largest collection - 170+ commands |
| Claude Code Plugins + Skills | Organized categories with tutorials |
| Superpowers | TDD, debugging, git worktrees |
| Claude Scientific Skills | Scientific computing skills |
### Installation Paths
| Platform | Default Path |
|----------|--------------|
| macOS/Linux | `~/.claude/skills/` |
| Windows | `%LOCALAPPDATA%\Claude\skills\` |
### Key Source Files
| File | Purpose |
|------|---------|
| `src/configs/skills-marketplace.ts` | Marketplace source definitions |
| `src/utils/skills.ts` | Skill file management utilities |
| `src/utils/skills-fetch.ts` | Skill download & installation |
| `src/ui/skills-menu/index.ts` | Skills management UI |
| `src/ui/skills-menu/marketplace.ts` | Marketplace browsing UI |
For complete details, see [`docs/SKILLS_GUIDE.md`](./docs/SKILLS_GUIDE.md).