refactor: apply claude-code architectural patterns to simplify SuperClaude - #120
Conversation
Inspired by analyzing ~/Desktop/claude-code's architecture: Pattern 1 (Filesystem IS the Registry): - Delete agents/DEPRECATED/ (240+ files) — superseded by tiered system - Delete agents/index.yaml — self-declared deprecated - Delete config/agents.yaml — redundant with agents/core/*.md files - Remove agent list from config/superclaud.yaml — filesystem handles discovery - Remove agent trigger duplication from superclaud.yaml — defined in frontmatter Pattern 2 (One Schema, Not Six Configs): - Delete config/mcp.yaml — self-declared "documentation only" - Strip dead keys from .claude/settings.json (superclaude, skills, guardrails blocks) - Remove stale config/models.yaml reference from superclaud.yaml Pattern 3 (Guardrails at Invocation): - enforced_guardrails in settings.json was never read by any code - Real enforcement already works via PreToolUse hooks (the correct pattern) Pattern 6 (Delete Dead Code): - Remove dashboard, snake-game, hangman-game crates from Cargo.toml workspace - Delete their source directories All 1981 tests pass. No functional changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pattern 5 (project-specific docs only): remove content that costs context window on every conversation without providing project-specific value. AGENTS.md: Replace generic "Repository Guidelines" (coding style, testing guidelines, commit conventions) with actual agent system documentation (3-tier architecture, frontmatter schema, agent creation guide). Generic conventions are handled by ruff/linters, not LLM context. CLAUDE.md: Remove duplicate GitNexus block (100 lines) already included via @AGENTS.md. Now 35 lines of unique PAL MCP content only. Delete template rule files (.claude/rules/architecture-reference.md, logging.md, project-conventions.md) — placeholder content consuming context on every session with no project-specific value. Combined context reduction: ~340 lines → ~211 lines (-38%). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pattern 6 (delete dead code, don't archive it): remove modules that are only imported by their own tests and superseded by core/ implementations. SuperClaude/Orchestrator/ (7 files, ~2,078 LOC) — async SDK-based loop runner replaced by core/loop_orchestrator.py (sync, signal-based). Active entry point is .claude/skills/sc-implement/scripts/loop_entry.py which imports from core/, not Orchestrator/. SuperClaude/Telemetry/ (3 files, ~300 LOC) — JSONL telemetry client only imported by dead Orchestrator/events_hooks.py. Active metrics system is core/metrics.py with pluggable callback interface. Also removes tests/orchestrator/ and tests/services/test_telemetry.py (tested the dead modules). Remaining tests: 1730 passed, 0 failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pattern 2 (one schema, not six config files): remove config files that no code reads and simplify the one that Rust crates actually consume. Deleted: - config/quality.yaml — self-declares "semantic references for LLM", not read by any Python or Rust code. Quality weights already in superclaud.yaml (which Rust crates DO read). - config/models.yaml — self-declares "for reference". PAL MCP's listmodels provides model info at runtime. - config/consensus_policies.yaml — only referenced in README. Simplified config/superclaud.yaml from 241 to 62 lines: - Removed: commands block, dynamic_loading, logging, performance, security, development, token_optimization, triggers, workflows, environment sections — none parsed by Rust SuperClaudeConfig struct. - Kept: version, name, modes, agents, quality, worktree, mcp_servers (the fields actually consumed by crates/superclaude-core). Updated README.md to remove references to deleted files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pattern 4 (transparent wrappers) + Pattern 6 (delete dead code): remove the SuperClaude/Agents/ package and its broken CLI consumer. The CLI `agent` command imported non-existent `AgentLoader`, so AGENT_AVAILABLE was always False — the command never worked. Similarly, scripts/report_agent_usage.py imported non-existent `usage_tracker`. Canonical agent selection lives in .claude/skills/sc-implement/scripts/select_agent.py (standalone, 551 LOC, JSON I/O) — used by the actual skill system. Deleted: - SuperClaude/Agents/ (registry.py, selector.py — 672 LOC) - setup/cli/commands/agent.py (broken CLI command) - scripts/report_agent_usage.py (broken imports) - tests/agents/ (tested dead code) - tests/scripts/test_report_agent_usage.py Updated SuperClaude/__main__.py to remove "agent" from CLI dispatch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedToo many files! This PR contains 299 files, which is 149 over the limit of 150. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (299)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ README Quality Check: 83/100 Structure Consistency: 100/100 See the Actions tab for the detailed report. |
GitNexus Impact Analysis⚪ NONE Overall Risk Level
Per-File Impact
Affected ProcessesAffected ModulesDetailed Impact by FileGenerated by GitNexus impact analysis |
Auto-generated update: 8994→6382 symbols (-29%) reflecting the removal of dead modules and deprecated agents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
✅ README Quality Check: 83/100 Structure Consistency: 100/100 See the Actions tab for the detailed report. |
Claude Code Review (via AWS Bedrock)OverviewThis PR represents a massive architectural cleanup applying 6 patterns from Anthropic's claude-code codebase to remove 58,360 lines of dead code, redundant configuration, and broken modules. The refactor deleted 365 files while adding only 91 lines, reducing the codebase by ~29% while preserving all genuine functionality. Critical IssuesNone identified. This is exemplary technical debt cleanup. High Priority Observations✅ Pattern Application ExcellenceThe PR systematically applies 6 architectural patterns with clear rationale:
✅ Test Coverage Validation
✅ Impact Metrics
Medium Priority ObservationsDocumentation Quality
Preserved FunctionalityAll genuine innovations remain untouched:
Code Quality
Positive Observations🎯 Architectural Maturity: Learning from reference implementations (claude-code) shows engineering discipline 🎯 Risk Management: PR author ran full test suite, linting, GitNexus reindex before submitting 🎯 Transparency: Commit history shows iterative cleanup (5 focused commits vs 1 massive dump) 🎯 No Scope Creep: Resisted temptation to add features during cleanup 🎯 Evidence-Based: Identified patterns by analyzing a real codebase, not theoretical principles Review Summary
Recommendation✅ APPROVE - Merge immediately This is a masterclass in technical debt cleanup:
The only risk is not merging - every day this sits open, new code might reference the dead modules. Generated by Claude Code Review (AWS Bedrock Sonnet 4.5) - Analyzed 365 file changes, 5 commits, 6 architectural patterns |
The security-engineer agent only existed in agents/DEPRECATED/ which was deleted. The eval referenced a non-existent file, causing the Claude CLI to receive an empty prompt (bash quoting broke on the f-string double quotes). Renamed to guardian (the active core security agent) and replaced the f-string with string concatenation to avoid shell quoting issues. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
✅ README Quality Check: 83/100 Structure Consistency: 100/100 See the Actions tab for the detailed report. |
Summary
Applies 6 architectural patterns learned from analyzing Anthropic's
claude-codeCLI codebase to remove dead code, redundant config, and broken modules from SuperClaude.agents/index.yaml,config/agents.yaml,config/superclaud.yamlagent lists) — filesystem discovery is the source of truthquality.yaml,models.yaml,mcp.yaml,consensus_policies.yaml), simplifiedsuperclaud.yamlfrom 241→62 linesenforced_guardrailsandguardrailsblocks fromsettings.json— real enforcement is via PreToolUse hooksSuperClaude/Agents/package (672 LOC) — broken CLI import (AgentLoadernever existed), canonical selection isselect_agent.pySuperClaude/Orchestrator/(2,078 LOC),SuperClaude/Telemetry/(300 LOC),agents/DEPRECATED/(240+ files), 3 unrelated Rust cratesImpact
What's preserved
All of SuperClaude's genuine innovations are untouched:
core/)Test plan
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest -m "not slow" tests/— 1,685 passed, 0 failuresruff check . && ruff format --check .— all clean🤖 Generated with Claude Code