# 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 keychain 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 keychain 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 keychain 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).