causantic 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -625,12 +625,16 @@ Analyze patterns across past sessions to surface recurring themes, problems, and
625
625
  dirName: 'causantic-cleanup',
626
626
  content: `---
627
627
  name: causantic-cleanup
628
- description: "Memory-informed codebase review and cleanup plan. Combines comprehensive code analysis with historical context from Causantic memory to create an actionable cleanup plan."
628
+ description: "Multi-agent codebase review and cleanup plan. Spawns specialist agents for infrastructure, design, documentation, and memory analysis, then synthesizes findings into a prioritised CLEANUP_PLAN.md."
629
629
  ---
630
630
 
631
- # Codebase Cleanup & Architecture Review
631
+ # Multi-Agent Codebase Cleanup & Architecture Review
632
632
 
633
- Perform a comprehensive review of the codebase and create a cleanup plan aligned to clean code and clean architecture principles, enriched with historical context from Causantic memory. Primary goals: audit dependency health (security vulnerabilities, deprecations, unmaintained projects), resolve linting errors and warnings, remove duplication, improve readability, eliminate dead code and artifacts, consolidate documentation, and enable high test coverage (70%+ target, ideally near 100%).
633
+ Perform a comprehensive, multi-agent review of the codebase and create a cleanup plan aligned to clean code and clean architecture principles, enriched with historical context from Causantic memory.
634
+
635
+ The work is split across parallel domain-specialist agents, each with a fresh context window, then findings are synthesized into the final CLEANUP_PLAN.md.
636
+
637
+ Primary goals: audit dependency health (security vulnerabilities, deprecations, unmaintained projects), resolve linting errors and warnings, remove duplication, improve readability, eliminate dead code and artifacts, consolidate documentation, and enable high test coverage (70%+ target, ideally near 100%).
634
638
 
635
639
  ## Invoke Planning Mode
636
640
 
@@ -638,212 +642,291 @@ Perform a comprehensive review of the codebase and create a cleanup plan aligned
638
642
 
639
643
  ---
640
644
 
641
- ## Phase 1: Codebase Discovery
645
+ ## Phase 1: Reconnaissance (Lead Agent)
646
+
647
+ Quick scan to gather enough context to brief the specialist agents. Duration: ~2 minutes of globbing/reading.
642
648
 
643
- ### 1.1 Project Structure Analysis
649
+ ### 1.1 Tech Stack & Project Structure
644
650
  - Map the directory structure and identify architectural layers
645
- - Identify entry points, core domain, and infrastructure boundaries
646
- - Note the tech stack, frameworks, and key dependencies
647
- - Find existing tests and assess current coverage
651
+ - Identify the tech stack, frameworks, and package manager
652
+ - Locate test framework, linter config, formatter config, CI config
653
+ - Find the main entry points and key files
648
654
 
649
- ### 1.2 Internal Dependency Analysis
650
- - Map internal dependencies between modules/packages
651
- - Identify circular dependencies
652
- - Check for dependency direction violations (dependencies should point inward)
653
- - Note coupling between modules
655
+ ### 1.2 Key File Inventory
656
+ - Package manifest (package.json, Cargo.toml, pyproject.toml, go.mod, etc.)
657
+ - Linter/formatter configuration files
658
+ - CI/CD pipeline configuration
659
+ - Test configuration
660
+ - Documentation files (README, docs/, CHANGELOG, etc.)
654
661
 
655
- ### 1.3 External Dependency Health Audit
662
+ ### 1.3 Build Reconnaissance Context Object
656
663
 
657
- **Version Currency & Updates:**
658
- - List all direct dependencies with current pinned version vs latest available
659
- - Identify dependencies more than one major version behind
660
- - Flag any dependencies with pending breaking changes in the next major version
661
- - Check for deprecated dependencies (marked deprecated by maintainers)
664
+ Assemble a context object to pass to each specialist:
662
665
 
663
- **Security Vulnerabilities:**
664
- - Run ecosystem security audit tools (\`cargo audit\`, \`npm audit\`, \`pip-audit\`, \`govulncheck\`, etc.)
665
- - Cross-reference dependencies against known vulnerability databases (RustSec, GitHub Advisory, NIST NVD)
666
- - Classify findings by severity: critical, high, medium, low
667
- - For each vulnerability, note whether a patched version exists
668
- - Check transitive (indirect) dependencies for vulnerabilities — not just direct ones
666
+ \`\`\`
667
+ Project: [name]
668
+ Root: [absolute path]
669
+ Tech Stack: [language, framework, package manager]
670
+ Test Framework: [framework, config location]
671
+ Linter: [tool, config location]
672
+ Formatter: [tool, config location]
673
+ CI: [tool, config location]
674
+ Key Files: [list of paths]
675
+ LOC Estimate: [approximate lines of code]
676
+ \`\`\`
669
677
 
670
- **Project Health & Sustainability:**
671
- For each dependency, assess maintenance health signals:
672
- - **Last release date** — flag if >12 months since last publish
673
- - **Last commit date** — flag if >6 months since last commit to default branch
674
- - **Open issues / PRs** — flag accumulating unanswered issues
675
- - **Bus factor** — flag single-maintainer projects for critical dependencies
676
- - **Download trends** — flag declining adoption (ecosystem-specific: crates.io, npm, PyPI)
677
- - **Funding / backing** — note whether the project has organisational support or is volunteer-only
678
- - **Ecosystem signals** — check for "looking for maintainer" notices, archived repos, or successor projects
678
+ **For small codebases (<5,000 LOC):** Note that a single-agent approach may be more efficient. Proceed with multi-agent if the user invoked this skill, but mention the option.
679
679
 
680
- **Risk Classification:**
681
- Classify each dependency into:
682
- | Risk Level | Criteria |
683
- |-----------|----------|
684
- | **Low** | Actively maintained, multiple contributors, backed by org, no known CVEs |
685
- | **Medium** | Maintained but single maintainer, or infrequent releases, or minor CVEs patched |
686
- | **High** | Unmaintained (>12 months), single maintainer gone, unpatched CVEs, or deprecated |
687
- | **Critical** | Known exploited vulnerabilities, abandoned with no successor, or archived |
680
+ \`\`\`
681
+ CHECKPOINT: Phase 1 complete - Reconnaissance
682
+ \`\`\`
688
683
 
689
- **Mitigation Strategies for High/Critical Risk:**
690
- For each high/critical risk dependency, recommend one of:
691
- 1. **Bump** newer version resolves the issue
692
- 2. **Replace** — suggest well-maintained alternative with migration path
693
- 3. **Fork** if no alternative exists, consider maintaining a fork
694
- 4. **Embed** — for small or thin dependencies, inline the relevant code to eliminate the external dependency entirely (reduces supply chain risk)
695
- 5. **Remove** — if the dependency is no longer needed
696
-
697
- ### 1.4 Linter & Static Analysis Audit
698
-
699
- **Run all configured linters with warnings enabled:**
700
- Detect the project's linting tools and run them in strict/pedantic mode to surface the full picture:
701
-
702
- | Ecosystem | Lint Command | Notes |
703
- |-----------|-------------|-------|
704
- | Rust | \`cargo clippy --workspace --all-features -- -W clippy::pedantic\` | Run both default and pedantic; separate findings by severity |
705
- | TypeScript/JS | \`eslint . --max-warnings 0\` or \`biome check .\` | Check for \`eslint-disable\` comments and \`@ts-ignore\` / \`@ts-expect-error\` suppressions |
706
- | Python | \`ruff check .\` or \`flake8 . --statistics\` | Also check \`mypy\`/\`pyright\` type errors |
707
- | Go | \`go vet ./...\` and \`staticcheck ./...\` | Check for \`//nolint\` directives |
708
- | General | Any project-specific linters in CI config or pre-commit hooks | Match what CI enforces |
709
-
710
- **Classify findings:**
711
- - **Errors** — code that won't compile, type errors, or lint rules configured as errors. These must be fixed.
712
- - **Warnings** — potential bugs, style issues, or best practice violations. Triage by category.
713
- - **Suppressions** — \`#[allow(...)]\`, \`// eslint-disable\`, \`@ts-ignore\`, \`# noqa\`, \`//nolint\`, etc. Audit each:
714
- - Is the suppression still necessary? (The underlying issue may have been fixed)
715
- - Is there a comment explaining why it's suppressed?
716
- - Can the code be refactored to eliminate the need for suppression?
717
-
718
- **Categorise lint findings:**
719
-
720
- | Category | Examples | Priority |
721
- |----------|---------|----------|
722
- | **Correctness** | Unused results, unchecked errors, unreachable code, type mismatches | High — likely bugs |
723
- | **Performance** | Unnecessary allocations, redundant clones, inefficient patterns | Medium — profile first |
724
- | **Style & Idiom** | Non-idiomatic patterns, naming conventions, import ordering | Low — batch fix |
725
- | **Complexity** | Overly complex expressions, deeply nested logic, long functions | Medium — readability |
726
- | **Deprecation** | Use of deprecated APIs, functions, or language features | High — will break on upgrade |
727
-
728
- **Formatter compliance:**
729
- - Run the project formatter (\`cargo fmt\`, \`prettier\`, \`black\`, \`gofmt\`, etc.) in check mode
730
- - Note any files that don't conform
731
- - Check if formatting is enforced in CI — if not, recommend adding it
732
-
733
- ### 1.5 Code Metrics Gathering
734
- - Identify large files (>300 lines) and complex functions (>30 lines)
735
- - Find files with high cyclomatic complexity
736
- - Locate code with deep nesting (>3 levels)
737
- - Note long parameter lists (>4 parameters)
684
+ ---
685
+
686
+ ## Phase 2: Spawn Specialist Agents
687
+
688
+ Spawn 4 specialist agents **in parallel** using the Task tool. Each agent is \`subagent_type: "general-purpose"\` (full tool access). Task subagents inherit the session's MCP connections, so the Memory specialist will have access to causantic MCP tools.
689
+
690
+ Pass each agent:
691
+ 1. The reconnaissance context from Phase 1
692
+ 2. Their domain-specific prompt (copied from the Specialist Prompts section below)
738
693
 
739
694
  \`\`\`
740
- ✓ CHECKPOINT: Phase 1 complete - Codebase Discovery
695
+ ✓ CHECKPOINT: Phase 2 complete - Specialists Spawned
741
696
  \`\`\`
742
697
 
743
698
  ---
744
699
 
745
- ## Phase 2: Memory-Informed Context Gathering
700
+ ## Phase 3: Synthesis (Lead Agent)
746
701
 
747
- **This phase uses Causantic memory to enrich the review with historical context.**
702
+ Collect the 4 specialist reports and synthesize into the final plan.
748
703
 
749
- ### 2.1 Decision History
750
- - Use \`recall\` to retrieve the episodic history behind major architectural decisions
751
- - Use \`search\` to find past discussions about code quality, tech debt, and refactoring
752
- - Document: why things are the way they are, what was tried before, what constraints exist
704
+ ### 3.1 Map Specialist Outputs
705
+ Map each specialist's output sections into the CLEANUP_PLAN.md template structure.
753
706
 
754
- ### 2.2 Known Tech Debt
755
- - Use \`recall\` with queries like "tech debt", "TODO", "workaround", "hack", "temporary" scoped to the project
756
- - Use \`predict\` to surface areas that memory suggests are problematic
757
- - Cross-reference memory findings with current code state
707
+ ### 3.2 Memory Cross-Referencing
708
+ For each infrastructure/design/docs finding, check if the memory report provides historical context that modifies the recommendation:
709
+ - Dependency pinned for a compatibility reason note in Version Bumps table
710
+ - Suppression added deliberately for an edge case → mark as "valid" in Suppression Audit
711
+ - Architecture chosen for a specific reason → note in Architecture Assessment
758
712
 
759
- ### 2.3 Past Cleanup Attempts
760
- - Use \`recall\` to search for previous refactoring or cleanup work
761
- - Note what was done before, what worked, and what was abandoned
762
- - Avoid recommending changes that were previously tried and rejected (unless circumstances changed)
713
+ ### 3.3 Contradiction Resolution
714
+ When memory contradicts a specialist finding:
715
+ - Include both perspectives
716
+ - Add a "⚠️ Requires human decision" flag
717
+ - Default to the safer option (e.g., keep the pin, keep the suppression)
763
718
 
764
- ### 2.4 Dependency History
765
- - Use \`recall\` to search for past dependency upgrade attempts, compatibility issues, or migration discussions
766
- - Use \`recall\` to understand why specific dependency versions may be pinned
767
- - Cross-reference memory findings with current dependency state avoid recommending upgrades that were previously tried and caused issues
719
+ ### 3.4 Deduplication
720
+ - Dead code findings from Infrastructure + unused code from Design merge into single Dead Code section
721
+ - When the same item appears from multiple specialists with different severity assessments, take the highest severity and annotate with the contributing perspectives
722
+ - Lint findings from Infrastructure + complexity findings from Design merge categories
768
723
 
769
- ### 2.5 Lint & Suppression History
770
- - Use \`recall\` to search for past discussions about lint suppressions, intentional \`eslint-disable\` or \`@ts-ignore\` additions
771
- - Check if past sessions document why certain warnings were left unfixed
772
- - Note when memory shows a suppression was deliberately added for a specific edge case
724
+ ### 3.5 Prioritised Backlog
725
+ Merge all findings into 13-tier priority ordering:
726
+ 1. **Security vulnerability fixes** patch or bump dependencies with known CVEs (critical/high first)
727
+ 2. **Lint errors & correctness warnings** fix compiler/linter errors and correctness-category warnings (likely bugs)
728
+ 3. **At-risk dependency mitigation** — replace, embed, or fork unmaintained/deprecated dependencies
729
+ 4. **Dead code removal** — quick wins that reduce noise
730
+ 5. **Formatter & style lint fixes** — run formatter, fix style warnings (standalone PR, no logic changes)
731
+ 6. **Dependency version bumps** — bring dependencies up to date (group minor/patch bumps)
732
+ 7. **Suppression audit** — remove stale lint suppressions
733
+ 8. **Unlocks testing** — refactors that enable high-value tests
734
+ 9. **Documentation consolidation** — reduce confusion and maintenance burden
735
+ 10. **High duplication** — consolidation opportunities
736
+ 11. **High complexity** — simplification targets
737
+ 12. **Architectural violations** — dependency direction fixes
738
+ 13. **Technical debt hotspots** — frequently changed problem areas
773
739
 
774
740
  \`\`\`
775
- ✓ CHECKPOINT: Phase 2 complete - Memory-Informed Context Gathering
741
+ ✓ CHECKPOINT: Phase 3 complete - Synthesis
776
742
  \`\`\`
777
743
 
778
744
  ---
779
745
 
780
- ## Phase 3: Documentation Review
781
-
782
- ### 3.1 Documentation Inventory
783
- - Locate all documentation files (README, docs/, wiki, inline docs)
784
- - Identify documentation types: API docs, architecture docs, setup guides, user guides
785
- - Map documentation to corresponding code/features
786
- - Note documentation format and tooling (markdown, JSDoc, Sphinx, etc.)
746
+ ## Phase 4: Write CLEANUP_PLAN.md
787
747
 
788
- ### 3.2 Documentation Quality Assessment
789
- - Check for outdated or stale documentation (doesn't match current code)
790
- - Identify duplicate documentation (same info in multiple places)
791
- - Find conflicting documentation (contradictory information)
792
- - Note incomplete documentation (missing critical sections)
793
- - Assess documentation accessibility and discoverability
748
+ Write the synthesized plan to \`CLEANUP_PLAN.md\` in the project root using the Output Format below.
794
749
 
795
- ### 3.3 Documentation Consolidation Plan
796
- - Recommend single source of truth for each topic
797
- - Identify documentation to merge, update, or remove
798
- - Suggest documentation structure aligned with project architecture
799
- - Propose automation for keeping docs in sync (doc generation, CI checks)
750
+ Present a brief summary to the user and prompt for review.
800
751
 
801
752
  \`\`\`
802
- ✓ CHECKPOINT: Phase 3 complete - Documentation Review
753
+ ✓ CHECKPOINT: Phase 4 complete - CLEANUP_PLAN.md Written
803
754
  \`\`\`
804
755
 
805
756
  ---
806
757
 
807
- ## Phase 4: Pattern Analysis
758
+ ## Specialist Prompts
808
759
 
809
- ### 4.1 Duplication Detection
810
- Search for:
811
- - Exact code duplicates (copy-paste)
812
- - Structural duplicates (same logic, different names)
813
- - Semantic duplicates (same purpose, different implementation)
814
- - Repeated patterns that could be abstracted
760
+ Each prompt below is a complete, self-contained block. Copy the entire section content (everything under the heading) into the Task tool's \`prompt\` parameter when spawning the specialist. Replace \`[INSERT RECONNAISSANCE CONTEXT HERE]\` with the actual reconnaissance context from Phase 1.
815
761
 
816
- ### 4.2 Dead Code & Artifact Detection
762
+ ### Specialist: Infrastructure
817
763
 
818
- **Dead and Unused Code:**
819
- - Unreachable code paths
820
- - Unused functions, methods, and classes
764
+ You are the Infrastructure Specialist for a codebase cleanup review. Your job is to perform mechanical, tool-heavy analysis of the project's external dependencies, security posture, linting health, and dead artifacts.
765
+
766
+ **Project Context:**
767
+ [INSERT RECONNAISSANCE CONTEXT HERE]
768
+
769
+ **Your Scope:**
770
+ You are responsible for the following analyses. Be thorough and report everything you find.
771
+
772
+ #### 1. External Dependency Health Audit
773
+
774
+ **1.1 Version Currency & Updates**
775
+ - List all direct dependencies with current pinned version vs latest available
776
+ - Identify dependencies more than one major version behind
777
+ - Flag deprecated dependencies (marked deprecated by maintainers)
778
+ - Check for pending breaking changes in the next major version
779
+
780
+ **1.2 Security Vulnerabilities**
781
+ - Run ecosystem security audit tools (\`npm audit\`, \`cargo audit\`, \`pip-audit\`, \`govulncheck\`, etc.)
782
+ - Classify findings by severity: critical, high, medium, low
783
+ - For each vulnerability, note whether a patched version exists
784
+ - Check transitive (indirect) dependencies for vulnerabilities
785
+
786
+ **1.3 Project Health & Sustainability**
787
+ For each dependency, assess maintenance health signals:
788
+ - **Last release date** — flag if >12 months since last publish
789
+ - **Last commit date** — flag if >6 months since last commit
790
+ - **Open issues / PRs** — flag accumulating unanswered issues
791
+ - **Bus factor** — flag single-maintainer projects for critical dependencies
792
+ - **Ecosystem signals** — archived repos, "looking for maintainer" notices, successor projects
793
+
794
+ **1.4 Risk Classification**
795
+ Classify each flagged dependency:
796
+
797
+ | Risk Level | Criteria |
798
+ |-----------|----------|
799
+ | **Low** | Actively maintained, multiple contributors, no known CVEs |
800
+ | **Medium** | Maintained but single maintainer, infrequent releases, or minor CVEs patched |
801
+ | **High** | Unmaintained (>12 months), single maintainer gone, unpatched CVEs, deprecated |
802
+ | **Critical** | Known exploited vulnerabilities, abandoned with no successor, archived |
803
+
804
+ **1.5 Mitigation Strategies (for High/Critical only)**
805
+ For each, recommend one of:
806
+ 1. **Bump** — newer version resolves the issue
807
+ 2. **Replace** — suggest well-maintained alternative
808
+ 3. **Fork** — if no alternative exists
809
+ 4. **Embed** — for small deps, inline the relevant code
810
+ 5. **Remove** — if no longer needed
811
+
812
+ #### 2. Lint & Static Analysis Audit
813
+
814
+ **2.1 Run Linters**
815
+ Detect the project's linting tools and run them in strict/pedantic mode:
816
+ - TypeScript/JS: \`eslint . --max-warnings 0\` or \`biome check .\`
817
+ - Rust: \`cargo clippy --workspace --all-features -- -W clippy::pedantic\`
818
+ - Python: \`ruff check .\` or \`flake8 . --statistics\`
819
+ - Go: \`go vet ./...\` and \`staticcheck ./...\`
820
+ - Also run any project-specific linters from CI config or pre-commit hooks
821
+
822
+ **2.2 Classify Findings**
823
+ - **Errors** — must be fixed
824
+ - **Warnings** — triage by category (correctness, performance, style, complexity, deprecation)
825
+ - **Suppressions** — audit each \`eslint-disable\`, \`@ts-ignore\`, \`# noqa\`, \`#[allow(...)]\`, \`//nolint\`:
826
+ - Is it still necessary?
827
+ - Is there an explanatory comment?
828
+ - Can the code be refactored to eliminate the need?
829
+
830
+ **2.3 Formatter Compliance**
831
+ - Run the project formatter in check mode (\`prettier --check\`, \`cargo fmt --check\`, \`black --check\`, etc.)
832
+ - List files that don't conform
833
+ - Note whether formatting is enforced in CI
834
+
835
+ #### 3. Dead Code & Artifact Detection
836
+
837
+ **3.1 Dead Code**
838
+ - Unused exports, functions, classes, methods
821
839
  - Unused variables and imports
822
- - Vestigial code from removed features
840
+ - Unreachable code paths
823
841
  - Commented-out code blocks
824
- - Deprecated code still present
825
842
 
826
- **Debugging Artifacts:**
827
- - Console.log, print statements, and debug output
843
+ **3.2 Debug Artifacts**
844
+ - Console.log, print statements, debug output
828
845
  - Hardcoded debug flags or conditions
829
- - Debug-only code paths
830
846
  - Temporary workarounds left in place
831
847
 
832
- **Testing Artifacts:**
848
+ **3.3 Stale Artifacts**
833
849
  - Orphaned test files for deleted code
834
- - Test fixtures no longer used
835
- - Mock data files that are stale
836
- - Test utilities that aren't called
837
-
838
- **Outdated Artifacts:**
839
- - Old configuration files (for removed tools/services)
840
- - Legacy migration scripts that have been applied
850
+ - Unused test fixtures and mock data
851
+ - Old configuration files for removed tools
841
852
  - Backup files (.bak, .old, .orig)
842
853
  - Generated files that should be in .gitignore
843
- - Old build outputs or cache directories
844
- - Stale lock files or dependency snapshots
845
854
 
846
- ### 4.3 Architecture Assessment
855
+ #### Output Format
856
+
857
+ Return your findings as a structured markdown report with these sections:
858
+
859
+ **Security Fixes**
860
+
861
+ | Dependency | Current | Fix Version | Vulnerability | Severity |
862
+ |-----------|---------|-------------|---------------|----------|
863
+
864
+ **At-Risk Dependencies**
865
+
866
+ | Dependency | Risk Level | Issue | Recommended Action | Alternative |
867
+ |-----------|-----------|-------|-------------------|-------------|
868
+
869
+ **Version Bumps**
870
+
871
+ | Dependency | Current | Latest | Breaking Changes | Notes |
872
+ |-----------|---------|--------|------------------|-------|
873
+
874
+ **Lint Findings — Errors**
875
+
876
+ | File:Line | Rule | Message |
877
+ |-----------|------|---------|
878
+
879
+ **Lint Findings — Warnings by Category**
880
+
881
+ | Category | Count | Examples | Suggested Approach |
882
+ |----------|-------|---------|-------------------|
883
+
884
+ **Suppression Audit**
885
+
886
+ | File:Line | Suppression | Still Needed? | Has Comment? | Action |
887
+ |-----------|------------|---------------|-------------|--------|
888
+
889
+ **Formatter Compliance**
890
+ [Files not conforming, CI enforcement status]
891
+
892
+ **Dead Code**
893
+
894
+ | Item | Location | Type |
895
+ |------|----------|------|
896
+
897
+ **Debug Artifacts**
898
+
899
+ | Item | Location | Type |
900
+ |------|----------|------|
901
+
902
+ **Stale Artifacts**
903
+
904
+ | Item | Location | Type |
905
+ |------|----------|------|
906
+
907
+ **Cap each table at 30 items.** If more exist, note the total count and say "N additional items not shown."
908
+
909
+ Be specific with file paths and line references. Report facts, not opinions.
910
+
911
+ ### Specialist: Design
912
+
913
+ You are the Design Specialist for a codebase cleanup review. Your job is to assess code quality, architecture, structure, duplication, and testability — areas that require reading comprehension and judgment rather than running tools.
914
+
915
+ **Project Context:**
916
+ [INSERT RECONNAISSANCE CONTEXT HERE]
917
+
918
+ **Your Scope:**
919
+ You are responsible for the following analyses. Read code thoroughly and provide specific, evidence-based findings.
920
+
921
+ #### 1. Project Structure & Internal Dependencies
922
+
923
+ **1.1 Internal Dependency Mapping**
924
+ - Map dependencies between modules/packages
925
+ - Identify circular dependencies
926
+ - Check dependency direction (should point inward toward domain)
927
+ - Note coupling between modules
928
+
929
+ **1.2 Architecture Assessment**
847
930
 
848
931
  **Clean Architecture Alignment:**
849
932
  - Is domain logic independent of frameworks and infrastructure?
@@ -852,41 +935,53 @@ Search for:
852
935
  - Is the domain free of I/O and side effects?
853
936
 
854
937
  **SOLID Principles:**
855
- - **S**: Are there classes/modules doing too much?
938
+ - **S**: Classes/modules doing too much? (list specific violations)
856
939
  - **O**: Can behaviour be extended without modification?
857
940
  - **L**: Are substitutions safe across inheritance?
858
941
  - **I**: Are interfaces minimal and focused?
859
942
  - **D**: Are high-level modules depending on abstractions?
860
943
 
861
- ### 4.4 Code Quality Assessment
944
+ #### 2. Code Quality Assessment
862
945
 
863
- **Readability:**
946
+ **2.1 Readability**
864
947
  - Are names self-documenting?
865
948
  - Is the code explicit over implicit?
866
949
  - Are functions small and focused?
867
- - Is nesting depth reasonable?
950
+ - Is nesting depth reasonable? (flag >3 levels)
868
951
 
869
- **Maintainability:**
952
+ **2.2 Maintainability**
870
953
  - Can components be understood in isolation?
871
954
  - Are side effects contained and explicit?
872
955
  - Is state management clear?
873
956
  - Are error paths handled consistently?
874
957
 
875
- \`\`\`
876
- CHECKPOINT: Phase 4 complete - Pattern Analysis
877
- \`\`\`
958
+ **2.3 Code Metrics**
959
+ - Identify large files (>300 lines) with reason they're large
960
+ - Complex functions (>30 lines) — list each with line count
961
+ - Functions with deep nesting (>3 levels)
962
+ - Long parameter lists (>4 parameters)
878
963
 
879
- ---
964
+ #### 3. Duplication Detection
965
+
966
+ Search for:
967
+ - **Exact duplicates**: copy-pasted code blocks
968
+ - **Structural duplicates**: same logic, different names/variables
969
+ - **Semantic duplicates**: same purpose, different implementation
970
+ - **Repeated patterns**: patterns that could be abstracted (but only if used 3+ times)
971
+
972
+ For each duplicate found, provide:
973
+ - Both locations (file:line)
974
+ - Approximate size (lines)
975
+ - Suggested consolidation approach
880
976
 
881
- ## Phase 5: Testability Analysis
977
+ #### 4. Testability Analysis
882
978
 
883
- ### 5.1 Current Test Assessment
884
- - Document existing test coverage percentage
885
- - Identify test types present (unit, integration, e2e)
979
+ **4.1 Current Test Assessment**
980
+ - Document existing test types (unit, integration, e2e)
886
981
  - Note testing frameworks and patterns in use
887
982
  - Find untested critical paths
888
983
 
889
- ### 5.2 Testability Barriers
984
+ **4.2 Testability Barriers**
890
985
  Identify code that is hard to test:
891
986
  - Tight coupling to infrastructure (DB, APIs, filesystem)
892
987
  - Hidden dependencies (singletons, global state)
@@ -894,164 +989,323 @@ Identify code that is hard to test:
894
989
  - Large functions doing multiple things
895
990
  - Missing dependency injection
896
991
 
897
- ### 5.3 Coverage Gap Analysis
992
+ **4.3 Coverage Gap Analysis**
898
993
  Prioritise untested areas by:
899
994
  1. Business criticality
900
995
  2. Change frequency
901
996
  3. Complexity/risk
902
997
  4. Ease of testing after refactor
903
998
 
904
- \`\`\`
905
- ✓ CHECKPOINT: Phase 5 complete - Testability Analysis
906
- \`\`\`
999
+ #### Output Format
907
1000
 
908
- ---
1001
+ Return your findings as a structured markdown report with these sections:
909
1002
 
910
- ## Phase 6: Cleanup Plan Creation
1003
+ **Architecture Assessment**
1004
+ [Clean architecture alignment findings, dependency direction violations]
911
1005
 
912
- ### 6.1 Dependency Actions
1006
+ **Internal Dependencies**
1007
+ [Module dependency map, circular dependencies, coupling issues]
913
1008
 
914
- **Immediate Security Fixes:**
915
- | Dependency | Current | Fix Version | Vulnerability | Severity |
916
- |-----------|---------|-------------|---------------|----------|
917
- | ... | ... | ... | CVE-... | critical/high |
1009
+ **SOLID Findings**
918
1010
 
919
- **Version Bumps:**
920
- | Dependency | Current | Latest | Breaking Changes | Notes |
921
- |-----------|---------|--------|------------------|-------|
922
- | ... | ... | ... | yes/no | ... |
1011
+ | Principle | File:Line | Violation | Severity | Suggestion |
1012
+ |-----------|-----------|-----------|----------|------------|
923
1013
 
924
- **At-Risk Dependencies:**
925
- | Dependency | Risk Level | Issue | Recommended Action |
926
- |-----------|-----------|-------|-------------------|
927
- | ... | high/critical | unmaintained/deprecated/... | replace with X / embed / fork / remove |
1014
+ **Code Quality**
928
1015
 
929
- For each at-risk dependency, include:
930
- - Why it's flagged (specific health signals)
931
- - Recommended alternative (if replacing), with brief comparison
932
- - Migration complexity estimate (trivial / moderate / significant)
933
- - If recommending embed: identify the specific functions/types used and estimate the inlining effort
1016
+ Large Files:
934
1017
 
935
- ### 6.2 Lint & Static Analysis Cleanup
1018
+ | File | Lines | Reason |
1019
+ |------|-------|--------|
936
1020
 
937
- **Errors (must fix):**
938
- | File | Line | Lint Rule | Message | Fix |
939
- |------|------|-----------|---------|-----|
940
- | ... | ... | ... | ... | ... |
1021
+ Complex Functions:
941
1022
 
942
- **Warnings by category:**
943
- | Category | Count | Examples | Suggested Approach |
944
- |----------|-------|---------|-------------------|
945
- | Correctness | N | unused Result in \`foo.ts:42\` | Fix individually — likely bugs |
946
- | Deprecation | N | \`old_api()\` in \`bar.ts:15\` | Migrate to replacement API |
947
- | Performance | N | unnecessary clone in \`baz.ts:88\` | Batch fix, profile first |
948
- | Style/Idiom | N | non-idiomatic match in \`qux.ts:20\` | Batch fix in single commit |
949
- | Complexity | N | cognitive complexity 25 in \`parse()\` | Refactor as part of Phase 4 |
950
-
951
- **Suppression audit:**
952
- | File | Line | Suppression | Still Needed? | Action |
953
- |------|------|------------|---------------|--------|
954
- | ... | ... | \`// eslint-disable\` | yes/no | keep with comment / remove / refactor |
955
-
956
- **Formatter fixes:**
957
- - List files not conforming to project formatter
958
- - Recommend: run formatter and commit as standalone PR (no logic changes)
959
-
960
- ### 6.3 Dead Code & Artifact Removal
961
-
962
- **Immediate Removal** (safe to delete):
963
- - Commented-out code (preserved in version control)
964
- - Unused imports and variables
965
- - Debug statements and logging
966
- - Backup and temporary files
967
- - Orphaned test files
968
-
969
- **Careful Removal** (verify before deleting):
970
- - Unused functions (check for dynamic calls)
971
- - Vestigial feature code (confirm feature is truly removed)
972
- - Old configuration (ensure not referenced)
973
- - Deprecated code (check for external consumers)
974
-
975
- ### 6.4 Documentation Updates
976
-
977
- **Documentation Actions:**
978
- | Document | Action | Reason |
979
- |----------|--------|--------|
980
- | ... | Keep/Update/Merge/Remove | ... |
1023
+ | Function | File:Line | Lines | Nesting Depth | Issue |
1024
+ |----------|-----------|-------|---------------|-------|
981
1025
 
982
- **Consolidation Tasks:**
983
- - Merge duplicate docs into single source
984
- - Update outdated documentation
985
- - Remove documentation for deleted features
986
- - Add missing critical documentation
1026
+ Long Parameter Lists:
987
1027
 
988
- ### 6.5 Refactoring Opportunities
1028
+ | Function | File:Line | Param Count |
1029
+ |----------|-----------|-------------|
989
1030
 
990
- Categorise findings into:
1031
+ **Duplication**
991
1032
 
992
- **Quick Wins** (low effort, high impact)
993
- - Remove dead code, unused imports, and debug statements
994
- - Extract duplicated code into shared utilities
995
- - Rename unclear variables/functions
996
- - Fix obvious SOLID violations
1033
+ | Location 1 | Location 2 | Size (lines) | Type | Consolidation Approach |
1034
+ |------------|------------|-------------|------|----------------------|
997
1035
 
998
- **Structural Improvements** (medium effort)
999
- - Extract classes/modules from large files
1000
- - Introduce missing abstractions
1001
- - Separate pure logic from side effects
1002
- - Add dependency injection where missing
1036
+ **Testability Report**
1003
1037
 
1004
- **Architectural Changes** (high effort)
1005
- - Restructure to proper layers
1006
- - Extract bounded contexts
1007
- - Introduce proper interfaces/ports
1008
- - Migrate to cleaner patterns
1038
+ Current State:
1039
+ [Test types present, frameworks, coverage if known]
1009
1040
 
1010
- ### 6.6 Testing Strategy
1041
+ Barriers:
1011
1042
 
1012
- For each area, recommend:
1013
- - What test types to add (unit/integration/e2e)
1014
- - What refactoring enables testing
1015
- - Order of test introduction
1016
- - Target coverage per module
1043
+ | Barrier | Location | Type | Impact on Testing |
1044
+ |---------|----------|------|-------------------|
1017
1045
 
1018
- **Testing Pyramid Target:**
1019
- - Unit tests: 70-80% of tests (fast, isolated)
1020
- - Integration tests: 15-25% (component boundaries)
1021
- - E2E tests: 5-10% (critical paths only)
1046
+ Coverage Gaps (Prioritised):
1022
1047
 
1023
- ### 6.7 Prioritised Backlog
1048
+ | Area | Priority | Reason | Prerequisite Refactor |
1049
+ |------|----------|--------|----------------------|
1024
1050
 
1025
- Create a prioritised list considering:
1026
- 1. **Security vulnerability fixes** patch or bump dependencies with known CVEs (critical/high first)
1027
- 2. **Lint errors & correctness warnings** — fix compiler/linter errors and correctness-category warnings (likely bugs)
1028
- 3. **At-risk dependency mitigation** — replace, embed, or fork unmaintained/deprecated dependencies
1029
- 4. **Dead code removal** — quick wins that reduce noise
1030
- 5. **Formatter & style lint fixes** — run formatter, fix style warnings (standalone PR, no logic changes)
1031
- 6. **Dependency version bumps** — bring dependencies up to date (group minor/patch bumps)
1032
- 7. **Suppression audit** — remove stale \`eslint-disable\` / \`@ts-ignore\` / \`# noqa\` directives
1033
- 8. **Unlocks testing** — refactors that enable high-value tests
1034
- 9. **Documentation consolidation** — reduce confusion and maintenance burden
1035
- 10. **High duplication** — consolidation opportunities
1036
- 11. **High complexity** — simplification targets (also addresses complexity lint warnings)
1037
- 12. **Architectural violations** — dependency direction fixes
1038
- 13. **Technical debt hotspots** — frequently changed problem areas
1051
+ Testing Strategy Recommendation:
1052
+ [Recommended approach per module/layer, testing pyramid target]
1039
1053
 
1040
- \`\`\`
1041
- ✓ CHECKPOINT: Phase 6 complete - Cleanup Plan Creation
1042
- \`\`\`
1054
+ **Cap each table at 30 items.** If more exist, note the total count and say "N additional items not shown."
1055
+
1056
+ Be specific with file paths and line references. Support findings with evidence from the code.
1057
+
1058
+ ### Specialist: Documentation
1059
+
1060
+ You are the Documentation Specialist for a codebase cleanup review. Your job is to audit all project documentation for accuracy, coverage, and structure — then recommend a consolidation plan.
1061
+
1062
+ **Project Context:**
1063
+ [INSERT RECONNAISSANCE CONTEXT HERE]
1064
+
1065
+ **Your Scope:**
1066
+ You are responsible for the following analyses.
1067
+
1068
+ #### 1. Documentation Inventory & Classification
1069
+
1070
+ **1.1 Find All Documentation**
1071
+ Locate all documentation files:
1072
+ - README files (root and nested)
1073
+ - docs/ directory contents
1074
+ - CHANGELOG, CONTRIBUTING, LICENSE, SECURITY, CODE_OF_CONDUCT
1075
+ - Inline documentation (JSDoc, rustdoc, docstrings, etc.)
1076
+ - Wiki or external documentation references
1077
+ - Architecture Decision Records (ADRs)
1078
+ - Configuration documentation
1079
+ - API documentation (OpenAPI specs, GraphQL schemas, etc.)
1080
+
1081
+ **1.2 Classify Each Document**
1082
+ For each document, classify as:
1083
+ - **Active** — describes current functionality, actively maintained
1084
+ - **Historical** — describes past decisions or deprecated features, kept for reference
1085
+ - **Generated** — auto-generated (API docs, type docs, etc.)
1086
+ - **Stale** — has not been updated to match current code
1087
+ - **Orphaned** — describes features/code that no longer exists
1088
+
1089
+ #### 2. Accuracy Audit
1090
+
1091
+ **2.1 Cross-Reference Against Implementation**
1092
+ For each active document:
1093
+ - Do code examples compile/run?
1094
+ - Do API descriptions match actual signatures?
1095
+ - Do configuration references match actual config schemas?
1096
+ - Do architecture descriptions match actual structure?
1097
+ - Are version numbers and compatibility claims current?
1098
+
1099
+ **2.2 Identify Inaccuracies**
1100
+ List specific inaccuracies with:
1101
+ - Document path and section
1102
+ - What the document says
1103
+ - What the code actually does
1104
+ - Suggested correction
1105
+
1106
+ #### 3. Coverage Gaps
1107
+
1108
+ **3.1 Enumerate Public Surface Area**
1109
+ - Public APIs, exported functions, CLI commands
1110
+ - Configuration options
1111
+ - Environment variables
1112
+ - Key architectural concepts
1113
+
1114
+ **3.2 Identify Undocumented Items**
1115
+ For each undocumented public item, note:
1116
+ - What it is and where it lives
1117
+ - Priority (high = user-facing, low = internal utility)
1118
+
1119
+ #### 4. Structure & Normalisation
1120
+
1121
+ **4.1 Overlap Analysis**
1122
+ - Find topics documented in multiple places
1123
+ - Identify contradictions between documents
1124
+ - Note redundant content
1125
+
1126
+ **4.2 Orphan Detection**
1127
+ - Documents referencing deleted files or features
1128
+ - Links to non-existent pages or sections
1129
+ - Stale cross-references
1130
+
1131
+ **4.3 Proposed Hierarchy**
1132
+ Recommend a documentation structure:
1133
+ - What is the single source of truth for each topic?
1134
+ - Which documents should be merged?
1135
+ - Which should be removed?
1136
+ - What new documents are needed?
1137
+
1138
+ #### Output Format
1139
+
1140
+ Return your findings as a structured markdown report with these sections:
1141
+
1142
+ **Inventory Summary**
1143
+
1144
+ | Document | Path | Type | Classification | Last Updated |
1145
+ |----------|------|------|---------------|-------------|
1146
+
1147
+ **Accuracy Findings**
1148
+
1149
+ | Document | Section | Issue | Current Content | Correct Content |
1150
+ |----------|---------|-------|-----------------|-----------------|
1151
+
1152
+ **Coverage Gaps**
1153
+
1154
+ | Item | Type | Location | Priority | Notes |
1155
+ |------|------|----------|----------|-------|
1156
+
1157
+ **Structure Recommendations**
1158
+
1159
+ Documents to Update:
1160
+
1161
+ | Document | Updates Required |
1162
+ |----------|-----------------|
1163
+
1164
+ Documents to Merge:
1165
+
1166
+ | Source | Target | Reason |
1167
+ |--------|--------|--------|
1168
+
1169
+ Documents to Remove:
1170
+
1171
+ | Document | Reason |
1172
+ |----------|--------|
1173
+
1174
+ New Documents Needed:
1175
+
1176
+ | Topic | Priority | Suggested Location |
1177
+ |-------|----------|-------------------|
1178
+
1179
+ **Cap each table at 30 items.** If more exist, note the total count and say "N additional items not shown."
1180
+
1181
+ ### Specialist: Memory
1182
+
1183
+ You are the Memory Specialist for a codebase cleanup review. Your job is to query Causantic long-term memory to surface historical context that informs the cleanup plan — decisions, tech debt, past attempts, and dependency history.
1184
+
1185
+ **Project Context:**
1186
+ [INSERT RECONNAISSANCE CONTEXT HERE]
1187
+
1188
+ **Your Scope:**
1189
+ Use the causantic MCP tools (\`recall\`, \`search\`, \`predict\`) to gather historical context. All queries should be scoped to the current project.
1190
+
1191
+ #### 1. Decision History
1192
+
1193
+ Query memory for architectural decisions and design choices:
1194
+ - \`recall\` query: "architectural decisions"
1195
+ - \`recall\` query: "design choices"
1196
+ - \`recall\` query: "why did we choose" (for rationale behind key choices)
1197
+ - \`search\` query: "decision" and "chose" and "alternative"
1198
+
1199
+ For each decision found, note:
1200
+ - What was decided
1201
+ - When (approximate)
1202
+ - Why (rationale)
1203
+ - What alternatives were considered
1204
+ - Whether circumstances have changed since
1205
+
1206
+ #### 2. Known Tech Debt
1207
+
1208
+ Query memory for acknowledged tech debt:
1209
+ - \`recall\` query: "tech debt"
1210
+ - \`search\` query: "TODO"
1211
+ - \`search\` query: "workaround"
1212
+ - \`search\` query: "hack"
1213
+ - \`search\` query: "temporary"
1214
+ - \`search\` query: "FIXME"
1215
+
1216
+ For each item found, note:
1217
+ - What the debt is
1218
+ - When it was introduced
1219
+ - Why (was it intentional? a time constraint?)
1220
+ - Whether it's been addressed since
1221
+
1222
+ #### 3. Past Cleanup Attempts
1223
+
1224
+ Query memory for previous refactoring or cleanup work:
1225
+ - \`recall\` query: "refactoring"
1226
+ - \`recall\` query: "cleanup"
1227
+ - \`recall\` query: "code review"
1228
+ - \`search\` query: "refactor"
1229
+
1230
+ For each attempt found, note:
1231
+ - What was attempted
1232
+ - What was completed vs abandoned
1233
+ - Why it was abandoned (if applicable)
1234
+ - Lessons learned
1235
+
1236
+ #### 4. Dependency History
1237
+
1238
+ Query memory for past dependency-related work:
1239
+ - \`recall\` query: "dependency upgrade"
1240
+ - \`recall\` query: "dependency pinned"
1241
+ - \`recall\` query: "migration"
1242
+ - \`search\` query: "compatibility issue"
1243
+ - \`search\` query: "breaking change"
1244
+
1245
+ For each item found, note:
1246
+ - Which dependency
1247
+ - What happened (upgrade attempt, pin, compatibility issue)
1248
+ - Outcome (success, failure, workaround)
1249
+ - Any ongoing constraints
1250
+
1251
+ #### 5. Lint & Suppression History
1252
+
1253
+ Query memory for deliberate lint decisions:
1254
+ - \`recall\` query: "lint suppression"
1255
+ - \`recall\` query: "eslint-disable"
1256
+ - \`recall\` query: "ts-ignore"
1257
+ - \`search\` query: "warning suppressed"
1258
+ - \`search\` query: "lint exception"
1259
+
1260
+ For each item found, note:
1261
+ - What was suppressed and where
1262
+ - Why it was suppressed
1263
+ - Whether the underlying issue has been resolved
1264
+
1265
+ #### Output Format
1266
+
1267
+ Return your findings as a structured markdown report with these sections:
1268
+
1269
+ **Decision History**
1270
+
1271
+ | Decision | When | Rationale | Alternatives | Current Relevance |
1272
+ |----------|------|-----------|-------------|-------------------|
1273
+
1274
+ **Known Tech Debt**
1275
+
1276
+ | Item | Introduced | Reason | Status | Source |
1277
+ |------|-----------|--------|--------|--------|
1278
+
1279
+ **Past Cleanup Attempts**
1280
+
1281
+ | Attempt | Scope | Outcome | Lessons |
1282
+ |---------|-------|---------|---------|
1283
+
1284
+ **Dependency History**
1285
+
1286
+ | Dependency | Event | Outcome | Constraints |
1287
+ |-----------|-------|---------|-------------|
1288
+
1289
+ **Lint/Suppression History**
1290
+
1291
+ | Suppression | Location | Reason | Resolved? |
1292
+ |------------|----------|--------|-----------|
1293
+
1294
+ **Cap each table at 30 items.** If more exist, note the total count and say "N additional items not shown."
1295
+
1296
+ If memory returns no results for a category, say "No memory found for [category]" — do not fabricate results.
1043
1297
 
1044
1298
  ---
1045
1299
 
1046
1300
  ## Output Format
1047
1301
 
1048
- Write the plan to \`CLEANUP_PLAN.md\` in project root with:
1302
+ Write the plan to \`CLEANUP_PLAN.md\` in the project root with:
1049
1303
 
1050
1304
  \`\`\`markdown
1051
1305
  # Codebase Cleanup Plan
1052
1306
 
1053
1307
  ## Executive Summary
1054
- [2-3 paragraph overview of findings and recommended approach]
1308
+ [2-3 paragraph overview of findings and recommended approach. Note any specialist gaps (agents that failed or returned no findings).]
1055
1309
 
1056
1310
  ## Current State
1057
1311
  - **Architecture**: [assessment]
@@ -1073,89 +1327,70 @@ Write the plan to \`CLEANUP_PLAN.md\` in project root with:
1073
1327
  ### Security Fixes (Priority)
1074
1328
  | Dependency | Current | Fix Version | Vulnerability | Severity |
1075
1329
  |-----------|---------|-------------|---------------|----------|
1076
- | ... | ... | ... | CVE-... | critical/high/medium |
1077
1330
 
1078
1331
  ### At-Risk Dependencies
1079
1332
  | Dependency | Risk | Issue | Action | Alternative / Notes |
1080
1333
  |-----------|------|-------|--------|---------------------|
1081
- | ... | high/critical | unmaintained since YYYY | replace / embed / fork | ... |
1082
1334
 
1083
1335
  ### Version Bumps
1084
1336
  | Dependency | Current | Latest | Breaking | Notes |
1085
1337
  |-----------|---------|--------|----------|-------|
1086
- | ... | ... | ... | yes/no | ... |
1087
1338
 
1088
1339
  ## Lint & Static Analysis
1089
1340
 
1090
1341
  ### Errors
1091
1342
  | File:Line | Rule | Message | Fix |
1092
1343
  |-----------|------|---------|-----|
1093
- | ... | ... | ... | ... |
1094
1344
 
1095
1345
  ### Warnings (by category)
1096
1346
  | Category | Count | Action |
1097
1347
  |----------|-------|--------|
1098
- | Correctness | N | Fix individually |
1099
- | Deprecation | N | Migrate APIs |
1100
- | Performance | N | Profile then fix |
1101
- | Style | N | Batch fix |
1102
- | Complexity | N | Refactor in Phase 4 |
1103
1348
 
1104
1349
  ### Suppression Audit
1105
1350
  | File:Line | Suppression | Verdict | Action |
1106
1351
  |-----------|------------|---------|--------|
1107
- | ... | \`// eslint-disable\` | stale/valid | remove / keep with comment |
1108
1352
 
1109
1353
  ## Dead Code & Artifact Removal
1110
1354
 
1111
1355
  ### Immediate Removal
1112
1356
  | Item | Location | Type | Notes |
1113
1357
  |------|----------|------|-------|
1114
- | ... | ... | dead code/debug/artifact | ... |
1115
1358
 
1116
1359
  ### Verify Before Removal
1117
1360
  | Item | Location | Verification Needed |
1118
1361
  |------|----------|---------------------|
1119
- | ... | ... | ... |
1120
1362
 
1121
1363
  ## Documentation Consolidation
1122
1364
 
1123
1365
  ### Documents to Update
1124
1366
  | Document | Updates Required |
1125
1367
  |----------|------------------|
1126
- | ... | ... |
1127
1368
 
1128
1369
  ### Documents to Remove/Merge
1129
1370
  | Document | Action | Target |
1130
1371
  |----------|--------|--------|
1131
- | ... | merge into | ... |
1132
1372
 
1133
1373
  ## Refactoring Roadmap
1134
1374
 
1135
1375
  ### Phase 0: Dependency Health (Security & Supply Chain)
1136
1376
  | Task | Impact | Effort | Dependencies Affected |
1137
1377
  |------|--------|--------|----------------------|
1138
- | ... | ... | ... | ... |
1139
1378
 
1140
1379
  ### Phase 1: Cleanup (Remove Noise)
1141
1380
  | Task | Impact | Effort | Files Affected |
1142
1381
  |------|--------|--------|----------------|
1143
- | ... | ... | ... | ... |
1144
1382
 
1145
1383
  ### Phase 2: Foundation (Enable Testing)
1146
1384
  | Task | Impact | Effort | Unlocks |
1147
1385
  |------|--------|--------|---------|
1148
- | ... | ... | ... | ... |
1149
1386
 
1150
1387
  ### Phase 3: Consolidation (Remove Duplication)
1151
1388
  | Task | Impact | Effort | Files Affected |
1152
1389
  |------|--------|--------|----------------|
1153
- | ... | ... | ... | ... |
1154
1390
 
1155
1391
  ### Phase 4: Architecture (Clean Structure)
1156
1392
  | Task | Impact | Effort | Components |
1157
1393
  |------|--------|--------|------------|
1158
- | ... | ... | ... | ... |
1159
1394
 
1160
1395
  ## Testing Strategy
1161
1396
  [Detailed testing approach per module/layer]
@@ -1172,6 +1407,25 @@ Write the plan to \`CLEANUP_PLAN.md\` in project root with:
1172
1407
 
1173
1408
  ---
1174
1409
 
1410
+ ## Synthesis Rules
1411
+
1412
+ 1. Map each specialist's output sections into the CLEANUP_PLAN.md template
1413
+ 2. **Memory cross-referencing**: For each infrastructure/design/docs finding, check if the memory report provides historical context that modifies the recommendation (e.g., dependency pinned for compatibility, suppression added deliberately, architecture chosen for specific reason)
1414
+ 3. **Contradiction resolution**: When memory contradicts a specialist, include both perspectives with a "⚠️ Requires human decision" flag. Default to the safer option.
1415
+ 4. **Deduplication**: Dead code findings from infrastructure + unused code from design — merge into single Dead Code section. When the same item appears from multiple specialists with different severity assessments, take the highest severity and annotate with the contributing perspectives.
1416
+ 5. **Prioritised backlog**: Merge all findings into the 13-tier priority ordering defined in Phase 3.
1417
+
1418
+ ---
1419
+
1420
+ ## Error Handling
1421
+
1422
+ - If a specialist returns no findings or fails: note the gap in Executive Summary, proceed with available data
1423
+ - If memory specialist fails: graceful degradation — omit Memory Context section, note gap
1424
+ - If all specialists fail: fall back to single-agent analysis of highest-priority areas (security, lint errors)
1425
+ - If the Task tool is unavailable or spawning fails: fall back to single-agent sequential analysis (Phase 1 areas first, then most critical from each specialist domain)
1426
+
1427
+ ---
1428
+
1175
1429
  ## Guidelines
1176
1430
 
1177
1431
  ### Do
@@ -1185,11 +1439,9 @@ Write the plan to \`CLEANUP_PLAN.md\` in project root with:
1185
1439
  - Note when memory shows a decision was deliberate vs accidental
1186
1440
  - Prioritise changes that unlock testing
1187
1441
  - Run ecosystem-specific audit tools (cargo audit, npm audit, etc.) for security findings
1188
- - Check GitHub/registry pages for dependency health signals (last release, contributors, issues)
1189
1442
  - Distinguish between direct and transitive dependency vulnerabilities
1190
1443
  - Provide concrete alternatives when flagging at-risk dependencies
1191
- - Estimate migration effort when suggesting dependency replacements
1192
- - Run linters in strict/pedantic mode to surface the full warning set, not just what CI enforces
1444
+ - Run linters in strict/pedantic mode to surface the full warning set
1193
1445
  - Audit every lint suppression — check if still needed and has an explanatory comment
1194
1446
  - Categorise lint findings (correctness vs style vs performance) so fixes can be batched sensibly
1195
1447
  - Recommend formatter-only commits as standalone PRs to keep diffs reviewable
@@ -1238,6 +1490,235 @@ Write the plan to \`CLEANUP_PLAN.md\` in project root with:
1238
1490
  - Consider breaking the plan into separate PRs for review
1239
1491
  - Dead code removal is often safest to do first as a separate PR
1240
1492
  - Documentation updates can be done in parallel with code changes
1493
+ `,
1494
+ },
1495
+ {
1496
+ dirName: 'causantic-roadmap',
1497
+ content: `---
1498
+ name: causantic-roadmap
1499
+ description: "Gather deferred work, cleanup findings, and user goals into a phased roadmap. Produces ROADMAP.md — designed to be shaped by human review."
1500
+ argument-hint: [goal]
1501
+ ---
1502
+
1503
+ # Project Roadmap
1504
+
1505
+ Gather candidate work items from multiple sources — cleanup findings, memory, codebase TODOs, and user-provided goals — then deduplicate, classify, and organize them into a phased roadmap for human review.
1506
+
1507
+ This is a synthesis task. The agent organizes; the human decides.
1508
+
1509
+ ## Invoke Planning Mode
1510
+
1511
+ **Before any analysis, enter planning mode.** The output of this skill is a draft roadmap for user approval and shaping.
1512
+
1513
+ ---
1514
+
1515
+ ## Phase 1: Gather Candidate Items
1516
+
1517
+ ### 1.1 Read Existing CLEANUP_PLAN.md
1518
+ If \`CLEANUP_PLAN.md\` exists in the project root:
1519
+ - Extract items from the Prioritised Backlog section
1520
+ - Tag each with source: "cleanup"
1521
+ - Only import backlog items, not every individual finding
1522
+
1523
+ ### 1.2 Read Existing ROADMAP.md
1524
+ If \`ROADMAP.md\` exists in the project root (updating an existing roadmap):
1525
+ - Carry forward all existing items
1526
+ - Preserve their current phase assignments and status
1527
+ - Tag each with source: "existing-roadmap"
1528
+
1529
+ ### 1.3 Query Causantic Memory
1530
+ Use the causantic MCP tools to surface deferred and aspirational work:
1531
+ - \`search\` query: "deferred"
1532
+ - \`search\` query: "aspirational"
1533
+ - \`search\` query: "someday"
1534
+ - \`search\` query: "future work"
1535
+ - \`search\` query: "TODO"
1536
+ - \`search\` query: "roadmap"
1537
+ - \`search\` query: "milestone"
1538
+ - \`search\` query: "release plan"
1539
+ - \`recall\` query: "features we want to build"
1540
+ - \`predict\` context: "project roadmap and future work"
1541
+ - Tag each with source: "memory"
1542
+
1543
+ If causantic MCP tools are unavailable or return nothing, note the gap and proceed with other sources.
1544
+
1545
+ ### 1.4 User-Provided Goals
1546
+ If the user passed arguments when invoking this skill:
1547
+ - Parse them as goals or feature descriptions
1548
+ - Tag each with source: "user"
1549
+
1550
+ ### 1.5 Scan Codebase for TODO/FIXME/HACK/XXX
1551
+ Search the codebase for inline markers:
1552
+ - \`TODO\`, \`FIXME\`, \`HACK\`, \`XXX\` comments
1553
+ - Tag each with source: "codebase-todo"
1554
+ - Include file path and line number
1555
+
1556
+ \`\`\`
1557
+ ✓ CHECKPOINT: Phase 1 complete - Candidates Gathered
1558
+ \`\`\`
1559
+
1560
+ ---
1561
+
1562
+ ## Phase 2: Deduplicate and Classify
1563
+
1564
+ ### 2.1 Merge and Deduplicate
1565
+ - Combine all candidate items
1566
+ - Deduplicate by semantic similarity (same work described differently across sources)
1567
+ - When merging duplicates, note all contributing sources
1568
+
1569
+ ### 2.2 Classify Each Item
1570
+
1571
+ | Field | Values |
1572
+ |-------|--------|
1573
+ | **Type** | security, bug, tech-debt, infrastructure, quality, feature, docs, aspirational |
1574
+ | **Source** | cleanup, existing-roadmap, memory, user, codebase-todo |
1575
+ | **Effort** | trivial, small, medium, large, epic |
1576
+ | **Impact** | low, medium, high, critical |
1577
+ | **Status** | new, carried-forward, in-progress, blocked |
1578
+
1579
+ ### 2.3 Group by Theme
1580
+ Organize items into logical themes (e.g., "Authentication", "Testing", "Performance", "Developer Experience").
1581
+
1582
+ \`\`\`
1583
+ ✓ CHECKPOINT: Phase 2 complete - Items Classified
1584
+ \`\`\`
1585
+
1586
+ ---
1587
+
1588
+ ## Phase 3: Dependency Analysis and Ordering
1589
+
1590
+ ### 3.1 Identify Dependencies
1591
+ - Which items depend on other items being completed first?
1592
+ - Which items conflict with each other?
1593
+
1594
+ ### 3.2 Identify Force Multipliers
1595
+ - Items that unlock multiple other items
1596
+ - Infrastructure work that reduces effort for downstream tasks
1597
+ - Quality improvements that make future work safer
1598
+
1599
+ ### 3.3 Propose Phased Ordering
1600
+
1601
+ | Phase | Name | Focus |
1602
+ |-------|------|-------|
1603
+ | 0 | Foundation | Security fixes, blockers, prerequisites |
1604
+ | 1 | Cleanup | Tech debt, dead code, lint fixes |
1605
+ | 2 | Infrastructure | Dependencies, CI/CD, test harness |
1606
+ | 3 | Quality | Coverage, documentation, code quality |
1607
+ | 4 | Features | New functionality |
1608
+ | 5 | Aspirational | Nice-to-haves, experiments |
1609
+
1610
+ Assign each item to a phase based on its type, dependencies, and impact.
1611
+
1612
+ \`\`\`
1613
+ ✓ CHECKPOINT: Phase 3 complete - Items Ordered
1614
+ \`\`\`
1615
+
1616
+ ---
1617
+
1618
+ ## Phase 4: Present Draft for Human Shaping
1619
+
1620
+ ### 4.1 Write ROADMAP.md
1621
+ Write the roadmap to \`ROADMAP.md\` in the project root using the Output Format below.
1622
+
1623
+ ### 4.2 Present Summary
1624
+ Show the user:
1625
+ - Total items by phase
1626
+ - Total items by source
1627
+ - Key force multipliers
1628
+ - Items flagged as "Requires human decision"
1629
+
1630
+ ### 4.3 Prompt for Review
1631
+ Ask the user to review and adjust:
1632
+ - Are the phase assignments correct?
1633
+ - Should any items be deferred or removed?
1634
+ - Are there missing items to add?
1635
+ - Is the priority ordering right?
1636
+
1637
+ \`\`\`
1638
+ ✓ CHECKPOINT: Phase 4 complete - ROADMAP.md Written
1639
+ \`\`\`
1640
+
1641
+ ---
1642
+
1643
+ ## Output Format
1644
+
1645
+ \`\`\`markdown
1646
+ # Project Roadmap
1647
+
1648
+ ## Executive Summary
1649
+ [Brief overview: how many items, where they came from, key themes]
1650
+
1651
+ ## Sources
1652
+ | Source | Items |
1653
+ |--------|-------|
1654
+ | Cleanup plan | N |
1655
+ | Memory | N |
1656
+ | Codebase TODOs | N |
1657
+ | User goals | N |
1658
+ | Existing roadmap | N |
1659
+
1660
+ ## Phase 0: Foundation
1661
+ | # | Item | Type | Effort | Impact | Source | Unlocks |
1662
+ |---|------|------|--------|--------|--------|---------|
1663
+
1664
+ ## Phase 1: Cleanup
1665
+ | # | Item | Type | Effort | Impact | Source | Unlocks |
1666
+ |---|------|------|--------|--------|--------|---------|
1667
+
1668
+ ## Phase 2: Infrastructure
1669
+ | # | Item | Type | Effort | Impact | Source | Unlocks |
1670
+ |---|------|------|--------|--------|--------|---------|
1671
+
1672
+ ## Phase 3: Quality
1673
+ | # | Item | Type | Effort | Impact | Source | Unlocks |
1674
+ |---|------|------|--------|--------|--------|---------|
1675
+
1676
+ ## Phase 4: Features
1677
+ | # | Item | Type | Effort | Impact | Source | Unlocks |
1678
+ |---|------|------|--------|--------|--------|---------|
1679
+
1680
+ ## Phase 5: Aspirational
1681
+ | # | Item | Type | Effort | Impact | Source | Unlocks |
1682
+ |---|------|------|--------|--------|--------|---------|
1683
+
1684
+ ## Deferred / Won't Do
1685
+ | Item | Reason |
1686
+ |------|--------|
1687
+
1688
+ ## Dependencies
1689
+ [Key dependency chains between items — which items must complete before others can start]
1690
+
1691
+ ## Notes
1692
+ [Any caveats, gaps in data sources, or items flagged for human decision]
1693
+ \`\`\`
1694
+
1695
+ ---
1696
+
1697
+ ## Error Handling
1698
+
1699
+ - If \`CLEANUP_PLAN.md\` doesn't exist: skip that source, note it in Sources table
1700
+ - If \`ROADMAP.md\` doesn't exist: this is a new roadmap (not an update)
1701
+ - If causantic MCP tools fail or return nothing: proceed with cleanup plan + TODOs + user goals, note the gap
1702
+ - If no sources produce any items: inform the user and suggest running \`/causantic-cleanup\` first
1703
+
1704
+ ---
1705
+
1706
+ ## Guidelines
1707
+
1708
+ ### Do
1709
+ - Present this as a **draft** for human shaping, not a final plan
1710
+ - Preserve item provenance (which source each item came from)
1711
+ - Highlight force multipliers — items that unlock many others
1712
+ - Group related items to show themes
1713
+ - Note when memory provides additional context on an item
1714
+ - Be specific about what each item entails
1715
+
1716
+ ### Don't
1717
+ - Include every individual lint warning or dead code instance from cleanup — only import Prioritised Backlog items
1718
+ - Make priority decisions the human should make — flag them for review instead
1719
+ - Fabricate items that aren't grounded in sources
1720
+ - Remove items from an existing roadmap without explanation
1721
+ - Over-specify effort estimates — use t-shirt sizes, not hours
1241
1722
  `,
1242
1723
  },
1243
1724
  {
@@ -1364,6 +1845,7 @@ Long-term memory is available via the \`causantic\` MCP server.
1364
1845
  - \`/causantic-crossref [pattern]\` — Search across all projects for reusable patterns
1365
1846
  - \`/causantic-retro [scope]\` — Surface recurring patterns, problems, and decisions across sessions
1366
1847
  - \`/causantic-cleanup\` — Memory-informed codebase review and cleanup plan
1848
+ - \`/causantic-roadmap [goal]\` — Gather deferred work and goals into a phased roadmap
1367
1849
 
1368
1850
  **Memory management:**
1369
1851
  - \`/causantic-forget [query or filters]\` — Delete memory by topic, time range, or session (always previews first)
@@ -1384,6 +1866,7 @@ Long-term memory is available via the \`causantic\` MCP server.
1384
1866
  | "Is there a pattern across projects?" | \`crossref\` |
1385
1867
  | "What patterns keep coming up?" | \`retro\` |
1386
1868
  | "Review the codebase" | \`cleanup\` |
1869
+ | "What should we work on next?" / "Build a roadmap" | \`roadmap\` |
1387
1870
  | "What projects are in memory?" | \`list-projects\` |
1388
1871
  | "Forget/delete memory about X" | \`forget\` |
1389
1872