---
actual_hours: null
assignees: []
created_at: '2025-08-20T09:26:09.177088'
dependencies: []
description: 'Migrate src/claude_mpm/cli/commands/agents.py to use the new shared
  utilities.


  ## Current State

  - 921 lines of code with significant duplication

  - Complex argument handling

  - Inconsistent error patterns

  - Mixed concerns in single function


  ## Target State

  - Use AgentCommand base class (extends BaseCommand)

  - Shared argument parsing for agent operations

  - Standardized error handling

  - Consistent output formatting


  ## Implementation Steps

  1. Import shared utilities: AgentCommand, handle_cli_errors, add_agent_arguments

  2. Create AgentsCommand class inheriting from AgentCommand

  3. Break down manage_agents function into smaller methods

  4. Replace argument parsing with shared patterns

  5. Update error handling to use CLIErrorHandler

  6. Implement consistent output formatting

  7. Test all agent operations (list, deploy, clean, etc.)


  ## Expected Outcome

  - ~40% code reduction (921 → ~550 lines)

  - Better separation of concerns

  - Consistent agent directory handling


  ## Files to Modify

  - src/claude_mpm/cli/commands/agents.py

  - src/claude_mpm/cli/parsers/agents_parser.py (if exists)


  ## Special Considerations

  - Agent directory resolution using PathResolver

  - Agent configuration loading using ConfigLoader

  - Multiple subcommands need individual handling'
due_date: null
estimated_hours: null
id: TSK-0129
labels: []
metadata:
  blocked_by: []
  blocks: []
  epic: EP-0002
  estimate: 1.5h
  github_id: I_kwDOPScCe87HDEuZ
  github_url: https://github.com/bobmatnyc/claude-mpm/issues/51
  parent: null
  platform: github
  subtasks: []
parent: null
priority: high
status: completed
tags: []
title: Refactor agents.py command to use shared utilities
updated_at: '2025-08-20T16:34:46.331254'
---

# Refactor agents.py command to use shared utilities

## Description
Migrate src/claude_mpm/cli/commands/agents.py to use the new shared utilities.

## Current State
- 921 lines of code with significant duplication
- Complex argument handling
- Inconsistent error patterns
- Mixed concerns in single function

## Target State
- Use AgentCommand base class (extends BaseCommand)
- Shared argument parsing for agent operations
- Standardized error handling
- Consistent output formatting

## Implementation Steps
1. Import shared utilities: AgentCommand, handle_cli_errors, add_agent_arguments
2. Create AgentsCommand class inheriting from AgentCommand
3. Break down manage_agents function into smaller methods
4. Replace argument parsing with shared patterns
5. Update error handling to use CLIErrorHandler
6. Implement consistent output formatting
7. Test all agent operations (list, deploy, clean, etc.)

## Expected Outcome
- ~40% code reduction (921 → ~550 lines)
- Better separation of concerns
- Consistent agent directory handling

## Files to Modify
- src/claude_mpm/cli/commands/agents.py
- src/claude_mpm/cli/parsers/agents_parser.py (if exists)

## Special Considerations
- Agent directory resolution using PathResolver
- Agent configuration loading using ConfigLoader
- Multiple subcommands need individual handling

## Details
- **Status**: completed
- **Priority**: high
- **Assignees**: None
- **Tags**: None
- **Created**: 2025-08-20 09:26:09
- **Updated**: 2025-08-20 16:34:46

## Tasks
- [ ] Add task items here

## Notes
_Add any additional notes or context here._
