Implement programmer agent system and consolidate agent infrastructure

Programmer Agent System:
- Add programmer-orchestrator (Opus) for workflow coordination
- Add code-planner (Sonnet) for design and planning
- Add code-implementer (Sonnet) for writing code
- Add code-reviewer (Sonnet) for quality review
- Add /programmer command and project registration skill
- Add state files for preferences and project context

Agent Infrastructure:
- Add master-orchestrator and linux-sysadmin agents
- Restructure skills to use SKILL.md subdirectory format
- Convert workflows from markdown to YAML format
- Add commands for k8s and sysadmin domains
- Add shared state files (model-policy, autonomy-levels, system-instructions)
- Add PA memory system (decisions, preferences, projects, facts)

Cleanup:
- Remove deprecated markdown skills and workflows
- Remove crontab example (moved to workflows)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OpenCode Test
2025-12-29 13:23:42 -08:00
parent 119d2a464e
commit 431e10b449
62 changed files with 3572 additions and 539 deletions

View File

@@ -0,0 +1,124 @@
# Status Line Agent Display + Keybind Fix
## Goal
1. Display `[personal-assistant] Opus | 45% context` in Claude Code status line
2. Fix Super+Shift+C keybind (terminal closes immediately)
## Root Cause: Keybind Issue
The `pa-mode` script creates a **detached** tmux session (`-d` flag) then attaches separately. This doesn't work well with `omarchy-launch-tui`. The working pattern uses `tmux -A` (attach-or-create in one step).
## Implementation
### Task 1: Create Status Line Script
**Create:** `~/.claude/automation/statusline.sh`
```bash
#!/usr/bin/env bash
input=$(cat)
AGENT="${CLAUDE_AGENT:-}"
MODEL=$(echo "$input" | jq -r '.model.display_name // "?"')
# Calculate context percentage
CONTEXT_PCT="?"
usage=$(echo "$input" | jq '.context_window.current_usage // empty')
if [ -n "$usage" ]; then
current=$(echo "$usage" | jq '.input_tokens + .cache_creation_input_tokens + .cache_read_input_tokens')
size=$(echo "$input" | jq '.context_window.context_window_size')
if [ "$size" -gt 0 ] 2>/dev/null; then
CONTEXT_PCT=$((current * 100 / size))
fi
fi
if [ -n "$AGENT" ]; then
echo "[$AGENT] $MODEL | ${CONTEXT_PCT}% context"
else
echo "$MODEL | ${CONTEXT_PCT}% context"
fi
```
### Task 2: Configure Status Line in Settings
**Modify:** `~/.claude/settings.json`
Add:
```json
{
"statusLine": {
"type": "command",
"command": "~/.claude/automation/statusline.sh"
}
}
```
### Task 3: Fix pa-mode Script
**Modify:** `~/.claude/automation/pa-mode`
Key changes:
1. Export `CLAUDE_AGENT=personal-assistant` before launching
2. Use `tmux new-session -A` (attach-or-create) instead of `-d` + separate attach
3. Remove the separate `attach_session` flow
New `create_or_attach_session()` function:
```bash
create_or_attach_session() {
local session_id
session_id=$(get_session_id)
local history_file="$HISTORY_DIR/${session_id}.jsonl"
# If session doesn't exist, record it in index
if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
local tmp_file
tmp_file=$(mktemp)
jq --arg id "$session_id" --arg started "$(date -Iseconds)" \
'.sessions += [{"id": $id, "started": $started, "ended": null, "summarized": false, "topics": []}]' \
"$INDEX_FILE" > "$tmp_file" && mv "$tmp_file" "$INDEX_FILE"
fi
# Export for status line, then attach-or-create
export CLAUDE_AGENT=personal-assistant
exec tmux new-session -A -s "$SESSION_NAME" -c "$HOME" \
"PA_SESSION_ID='$session_id' PA_HISTORY_FILE='$history_file' CLAUDE_AGENT=personal-assistant claude --dangerously-skip-permissions --agent personal-assistant"
}
```
Note: Using `exec` replaces the shell process with tmux, keeping the terminal open.
### Task 4: Verify Hyprland Keybind
**File:** `~/.config/hypr/bindings.conf` (line 34)
Current (should work after pa-mode fix):
```
bindd = SUPER SHIFT, C, PA Agent Mode, exec, omarchy-launch-tui /home/will/.claude/automation/pa-mode
```
No changes needed if pa-mode fix works. If still broken, fallback to:
```
bindd = SUPER SHIFT, C, PA Agent Mode, exec, uwsm-app -- xdg-terminal-exec -e /home/will/.claude/automation/pa-mode
```
## Files to Modify
| File | Action |
|------|--------|
| `~/.claude/automation/statusline.sh` | Create |
| `~/.claude/settings.json` | Add statusLine config |
| `~/.claude/automation/pa-mode` | Fix session creation, add CLAUDE_AGENT export |
| `~/.config/hypr/bindings.conf` | Maybe adjust if fix doesn't work |
## Testing
1. Run `pa-mode` from terminal - should open tmux with claude
2. Check status line shows `[personal-assistant] Opus | X% context`
3. Press Super+Shift+C - terminal should stay open with PA session
4. Detach (Ctrl+B, D), press Super+Shift+C again - should reattach
## Commits
1. `feat: add status line script with agent display`
2. `fix: pa-mode keybind issue - use tmux -A and exec`

View File

@@ -0,0 +1,149 @@
# Plan: Restructure Claude Code Components
## Summary
Reclassify misplaced skill files as commands, standardize workflow format to YAML, and add cross-references between components.
---
## Decisions Made
| Decision | Choice |
|----------|--------|
| Handle misclassified skills | Move to commands as thin wrappers |
| Workflow format | Keep YAML, convert Markdown to YAML |
| Cross-references | Add inline links in command files |
---
## Task 1: Move Misclassified Skills to Commands
These files use `/command` syntax and should be commands, not skills.
### 1.1 Create `/cluster-status` command
**Delete:** `~/.claude/skills/cluster-status.md`
**Create:** `~/.claude/commands/k8s/cluster-status.md`
```yaml
---
name: cluster-status
description: Get quick cluster health overview
aliases: [status, cs]
---
```
Content: Thin wrapper referencing `cluster-health-check` workflow.
### 1.2 Create `/deploy` command
**Delete:** `~/.claude/skills/deploy.md`
**Create:** `~/.claude/commands/k8s/deploy.md`
```yaml
---
name: deploy
description: Deploy application to K8s cluster
aliases: [d]
---
```
Content: Thin wrapper referencing `deploy-app` workflow.
### 1.3 Create `/diagnose` command
**Delete:** `~/.claude/skills/diagnose.md`
**Create:** `~/.claude/commands/k8s/diagnose.md`
```yaml
---
name: diagnose
description: Investigate cluster issues
aliases: [diag]
---
```
Content: Thin wrapper referencing incident workflows.
---
## Task 2: Convert Workflow to YAML
**File:** `~/.claude/workflows/deploy/deploy-app.md`
**Convert to:** `~/.claude/workflows/deploy/deploy-app.yaml`
Restructure as proper YAML workflow matching other workflow files.
---
## Task 3: Add Cross-References to Existing Commands
Update existing commands to explicitly reference what they invoke:
### 3.1 Update `/health` command
**File:** `~/.claude/commands/sysadmin/health.md`
Add: `invokes: skill:sysadmin-health`
### 3.2 Update `/update` command
**File:** `~/.claude/commands/sysadmin/update.md`
Add: `invokes: workflow:sysadmin/system-update`
### 3.3 Update `/autonomy` command
**File:** `~/.claude/commands/sysadmin/autonomy.md`
Add: `modifies: state:sysadmin/session-autonomy`
---
## Task 4: Update CLAUDE.md with Component Conventions
**File:** `~/.claude/CLAUDE.md`
Add section documenting:
- Format conventions (when to use JSON vs YAML vs Markdown)
- Component relationships (commands → skills → workflows)
- Naming patterns
---
## Files to Create
| File | Purpose |
|------|---------|
| `~/.claude/commands/k8s/cluster-status.md` | Cluster status command |
| `~/.claude/commands/k8s/deploy.md` | Deploy command |
| `~/.claude/commands/k8s/diagnose.md` | Diagnose command |
| `~/.claude/workflows/deploy/deploy-app.yaml` | Converted workflow |
## Files to Delete
| File | Reason |
|------|--------|
| `~/.claude/skills/cluster-status.md` | Moved to commands |
| `~/.claude/skills/deploy.md` | Moved to commands |
| `~/.claude/skills/diagnose.md` | Moved to commands |
| `~/.claude/workflows/deploy/deploy-app.md` | Converted to YAML |
## Files to Modify
| File | Change |
|------|--------|
| `~/.claude/commands/sysadmin/health.md` | Add invokes reference |
| `~/.claude/commands/sysadmin/update.md` | Add invokes reference |
| `~/.claude/commands/sysadmin/autonomy.md` | Add modifies reference |
| `~/.claude/CLAUDE.md` | Add component conventions |
---
## Execution Order
1. Create `~/.claude/commands/k8s/` directory
2. Create 3 new command files
3. Delete 3 misclassified skill files
4. Convert deploy-app.md to deploy-app.yaml
5. Update existing command files with cross-references
6. Update CLAUDE.md with conventions

View File

@@ -0,0 +1,52 @@
# Handoff: Linux Sysadmin Agent Implementation
## Context
Brainstorming session completed for building a Linux sysadmin AI agent.
## Plan Location
`/home/will/.claude/plans/shimmering-discovering-bonbon.md`
## What Was Decided
### Architecture
- Multi-agent system with **master-orchestrator** (Opus) overseeing all agents
- New **linux-sysadmin** agent (Sonnet) for Arch Linux workstation
- Existing K8s agents become managed by master-orchestrator
- Shared state files in `~/.claude/state/` for cross-agent awareness
### Linux Sysadmin Agent
- **Target**: Arch Linux with pacman/yay/homebrew
- **Scope**: Full sysadmin (maintenance, troubleshooting, config, security)
- **Autonomy**: Conservative by default (confirm all changes), session-configurable
- **Interaction**: CLI + scheduled, alerting deferred
### Key Design Decisions
- Claude Code compatible (Markdown + YAML frontmatter for agents)
- JSON files for state/data (not agent definitions)
- Model selection policy for cost efficiency (haiku → sonnet → opus)
- Agents can delegate to multiple subagents (parallel/sequential)
- `system-instructions.json` captures all processes
- `future-considerations.json` tracks deferred items (all agents aware)
### Settings.json Cleanup Required
- Remove non-standard `agents` field with `promptFile` entries
- Keep only standard Claude Code settings
## Implementation Order (20 steps, 7 phases)
1. Foundation (state files, CLAUDE.md)
2. Master orchestrator agent
3. Linux sysadmin agent
4. Update existing K8s agents
5. Clean settings.json
6. Skills & slash commands
7. Workflows
## Future Considerations to Track
- Prometheus/Alertmanager for workstation alerting
- Network admin agent
- Personal assistant agent
- External LLM integration
- Slash commands redesign
## Next Action
Read the full plan and begin Phase 1: Foundation

View File

@@ -0,0 +1,228 @@
# Linux Sysadmin Agent - Implementation Plan
## Overview
Create a Linux sysadmin agent for Arch Linux workstation management, integrated into a multi-agent system with a master orchestrator overseeing all agents.
## Architecture
```
~/.claude/
├── CLAUDE.md # Shared memory: conventions, state file locations
├── agents/
│ ├── master-orchestrator.md # NEW: oversight layer (Opus)
│ ├── linux-sysadmin.md # NEW: workstation agent (Sonnet)
│ ├── k8s-orchestrator.md # UPDATE: add shared state awareness
│ ├── k8s-diagnostician.md # UPDATE: add shared state awareness
│ ├── argocd-operator.md # UPDATE: add shared state awareness
│ ├── prometheus-analyst.md # UPDATE: add shared state awareness
│ └── git-operator.md # UPDATE: add shared state awareness
├── state/
│ ├── system-instructions.json # NEW: central process definitions
│ ├── future-considerations.json # NEW: deferred features/decisions
│ ├── model-policy.json # NEW: cost-efficient model selection rules
│ ├── autonomy-levels.json # NEW: shared autonomy definitions
│ └── sysadmin/
│ └── session-autonomy.json # NEW: per-session overrides
├── skills/
│ └── sysadmin-health/
│ └── SKILL.md # NEW: health check skill
├── commands/
│ └── sysadmin/
│ ├── health.md # NEW: /health slash command
│ └── update.md # NEW: /update slash command
├── workflows/
│ └── sysadmin/
│ ├── health-check.yaml # NEW: scheduled workflow
│ └── system-update.yaml # NEW: manual workflow
├── automation/
│ └── sysadmin/
│ └── scripts/ # NEW: managed scripts directory
└── settings.json # UPDATE: remove non-standard agent fields
```
## Agent Hierarchy
```
Master Orchestrator (Opus) - monitor, coordinate, enforce
├── linux-sysadmin (Sonnet) - workstation management
├── k8s-orchestrator (Opus) - cluster management
│ ├── k8s-diagnostician (Sonnet)
│ ├── argocd-operator (Sonnet)
│ ├── prometheus-analyst (Sonnet)
│ └── git-operator (Sonnet)
├── network-agent (future)
└── personal-assistant (future)
```
## Linux Sysadmin Agent Specification
### Target Environment
- **OS**: Arch Linux (rolling release)
- **Package managers**: pacman, yay (AUR), homebrew
- **Init system**: systemd
### Responsibilities
- **System maintenance**: Package updates, cache cleanup, log rotation, orphan removal
- **Troubleshooting**: Analyze journalctl logs, diagnose failed services, identify bottlenecks
- **Configuration**: Manage systemd services, edit configs (with approval), dotfile awareness
- **Security**: Monitor failed logins, check firewall, identify vulnerable packages
- **Health reporting**: Disk, memory, CPU, swap, service status, pending updates
### Tools
**Safe (auto-execute):**
- `journalctl`, `systemctl status`, `pacman -Q*`, `yay -Q*`, `brew list`
- `df`, `free`, `top`, `ps`, `ip`, `ss`, `uname`, `lsblk`, `findmnt`
- `uptime`, `last`, `who`
**Confirm (require approval):**
- `pacman -S/R/Syu`, `yay -S/R`, `brew install/upgrade`
- `systemctl start/stop/restart/enable/disable`
- Config file edits, `ansible-playbook`
**Forbidden:**
- `rm -rf /`, `dd` on system disks, `chmod -R 777`
- Kernel parameter changes without explicit request
- Anything touching `/boot` without confirmation
### Autonomy Model
Default: **Conservative** (read-only, confirm all changes)
```json
{
"levels": {
"conservative": "Confirm all write operations",
"moderate": "Auto-execute routine maintenance, confirm installs/removals",
"trusted": "Auto-execute most operations, confirm only destructive"
},
"session_override": "~/.claude/state/sysadmin/session-autonomy.json"
}
```
## Master Orchestrator Specification
### Responsibilities
1. **Monitor**: Watch agent activity, detect anomalies, track pending approvals
2. **Coordinate**: Route cross-agent requests, prevent conflicts
3. **Enforce**: Validate autonomy rules, block forbidden actions, escalate to user
4. **Memory**: Maintain shared state files (all agents read, master writes)
### Cross-Agent Communication Flow
```
Agent A → Master Orchestrator → Agent B
(route, validate, log)
```
## Model Selection Policy
```json
{
"opus": ["complex reasoning", "cross-agent coordination", "policy enforcement"],
"sonnet": ["standard operations", "well-defined tasks", "routine automation"],
"haiku": ["simple queries", "status checks", "log parsing", "data extraction"]
}
```
**Cost rules:**
1. Start with lowest capable model
2. Escalate only when task complexity requires
3. Agents may request model upgrade from orchestrator
4. Log model usage for cost analysis
## Multi-Subagent Delegation
Agents can delegate to multiple subagents:
- **Parallel**: Independent tasks run simultaneously
- **Sequential**: Dependent tasks run in order
- **Model override**: Request specific model per delegation
## Shared State Files
| File | Purpose | Writer |
|------|---------|--------|
| `system-instructions.json` | Central process definitions | master-orchestrator |
| `future-considerations.json` | Deferred features/decisions | master-orchestrator |
| `model-policy.json` | Model selection rules | master-orchestrator |
| `autonomy-levels.json` | Autonomy definitions | master-orchestrator |
| `session-autonomy.json` | Per-session overrides | user/CLI |
All agents MUST be aware of these files and follow the processes defined within.
## Implementation Steps
### Phase 1: Foundation
1. Create `state/system-instructions.json`
2. Create `state/future-considerations.json`
3. Create `state/model-policy.json`
4. Create `state/autonomy-levels.json`
5. Update `CLAUDE.md` with shared state locations
### Phase 2: Master Orchestrator
6. Create `agents/master-orchestrator.md` with YAML frontmatter
### Phase 3: Linux Sysadmin Agent
7. Create `agents/linux-sysadmin.md` with YAML frontmatter
8. Create `state/sysadmin/` directory structure
### Phase 4: Update Existing Agents
9. Update `agents/k8s-orchestrator.md` - add shared state awareness
10. Update `agents/k8s-diagnostician.md` - add shared state awareness
11. Update `agents/argocd-operator.md` - add shared state awareness
12. Update `agents/prometheus-analyst.md` - add shared state awareness
13. Update `agents/git-operator.md` - add shared state awareness
### Phase 5: Clean Settings
14. Update `settings.json` - remove non-standard `agents` field with `promptFile`
### Phase 6: Skills & Commands
15. Create `skills/sysadmin-health/SKILL.md`
16. Create `commands/sysadmin/health.md`
17. Create `commands/sysadmin/update.md`
### Phase 7: Workflows
18. Create `workflows/sysadmin/health-check.yaml`
19. Create `workflows/sysadmin/system-update.yaml`
20. Create `automation/sysadmin/scripts/` directory
## Future Considerations
Track in `state/future-considerations.json`:
| ID | Category | Description | Priority |
|----|----------|-------------|----------|
| fc-001 | infrastructure | Prometheus node_exporter + Alertmanager for workstation | medium |
| fc-002 | agent | Network admin agent | medium |
| fc-003 | agent | Personal assistant agent | medium |
| fc-004 | integration | External LLM integration (non-Claude models) | low |
| fc-005 | optimization | Model usage logging and cost tracking | medium |
| fc-006 | design | Revisit slash commands design | low |
| fc-007 | optimization | Optimize document structure/format | low |
## Critical Files to Modify
- `~/.claude/agents/k8s-orchestrator.md`
- `~/.claude/agents/k8s-diagnostician.md`
- `~/.claude/agents/argocd-operator.md`
- `~/.claude/agents/prometheus-analyst.md`
- `~/.claude/agents/git-operator.md`
- `~/.claude/settings.json`
- `~/.claude/CLAUDE.md`
## Agent File Format (Claude Code Required)
All agents must use Markdown with YAML frontmatter:
```markdown
---
name: agent-name
description: When to use this agent
model: sonnet|opus|haiku
tools: Tool1, Tool2, Tool3
---
[Agent instructions in Markdown]
```

View File

@@ -0,0 +1,39 @@
# Plan: Remove Redundancy + Add No-Redundancy Rule
## Identified Redundancies
| Item | CLAUDE.md | system-instructions.json | Action |
|------|-----------|--------------------------|--------|
| Conventions | Lines 63-67 | Lines 55-59 | Remove from JSON (CLAUDE.md is human reference) |
| State file writers | Lines 23-29 table | Lines 37-42 | Keep both - different purposes (table vs structured) |
| Key Processes | Lines 31-47 | Lines 5-34 | OK - CLAUDE.md is summary, JSON is canonical |
## Changes Required
### 1. Remove `conventions` from `system-instructions.json`
Already documented in CLAUDE.md - no need to duplicate.
### 2. Add no-redundancy principle to `CLAUDE.md`
Add to Conventions section:
```
- **No duplication**: Information lives in one place. CLAUDE.md = overview, JSON = details
```
### 3. Add to `system-instructions.json`
Add principle:
```json
"content-principles": {
"no-redundancy": "Information lives in one authoritative location",
"lean-files": "Keep files concise - no verbose examples or unnecessary prose"
}
```
## Files to Modify
| File | Action |
|------|--------|
| `~/.claude/state/system-instructions.json` | Remove conventions, add content-principles |
| `~/.claude/CLAUDE.md` | Add no-duplication rule to conventions |

View File

@@ -0,0 +1,82 @@
# Plan: K8s Agent Production Validation
## Goal
Address the identified gaps in k8s agent production readiness:
1. Create a lightweight k8s skill for quick checks (parallel to existing workflow)
2. Validate agents against live cluster with read-only operations
## Context
**Already exists:**
- `/cluster-status` command → `cluster-health-check` workflow (multi-step, 4 agents)
- All k8s agents are defined with proper boundaries and formats
**Gap:** No single-agent skill for ultra-quick status (like `sysadmin-health` for linux).
---
## Phase 1: Create K8s Quick-Status Skill
Create `~/.claude/skills/k8s-quick-status/SKILL.md`
**Purpose:** Lightweight single-agent check (haiku) for instant cluster pulse. Faster than workflow when you just need basics.
**Checks:**
- `kubectl get nodes` - node readiness
- `kubectl get pods -A --field-selector=status.phase!=Running` - unhealthy pods
- `kubectl get events -A --field-selector=type=Warning --sort-by='.lastTimestamp'` - recent warnings
- `argocd app list` - sync status at a glance
**Format:** Match `sysadmin-health` structure exactly (YAML frontmatter + Markdown).
---
## Phase 2: Live Cluster Validation
Run read-only commands to validate connectivity and output quality.
### Test Sequence
| Agent | Commands | Purpose |
|-------|----------|---------|
| k8s-diagnostician | `kubectl get nodes -o wide`<br>`kubectl get pods -A`<br>`kubectl top nodes` | Cluster connectivity |
| prometheus-analyst | `curl localhost:9090/api/v1/query?query=up`<br>`curl localhost:9090/api/v1/alerts` | Metrics access |
| argocd-operator | `argocd app list` | GitOps connectivity |
| git-operator | `git -C <gitops-repo> log --oneline -n 5` | Repo access |
### Success Criteria
- All commands execute without error
- kubectl has valid kubeconfig
- Prometheus is reachable
- ArgoCD CLI is authenticated
- Git repo is accessible
---
## Phase 3: Document Results
Update `~/.claude/state/future-considerations.json` with:
- Validation status per agent
- Any connectivity issues discovered
- Recommendations for fixes
---
## Files to Create/Modify
| File | Action |
|------|--------|
| `~/.claude/skills/k8s-quick-status/SKILL.md` | Create |
| `~/.claude/state/future-considerations.json` | Update |
---
## Execution Order
1. Create `k8s-quick-status` skill
2. Run kubectl connectivity test
3. Run Prometheus connectivity test
4. Run ArgoCD connectivity test
5. Run Git repo connectivity test
6. Document findings in `future-considerations.json`
7. Report summary