Hmm, the user wants a pipeline for continuous codebase archaeology—this is a niche but valuable concept. They're likely a tech lead or architect dealing with legacy systems, trying to balance maintenance with innovation. The term "dead paths" suggests they're wrestling with unused code or outdated patterns, and "historical decisions" implies they want to preserve institutional knowledge.
The challenge here is designing something actionable yet lightweight enough for continuous use. Can't be a one-off audit—needs to integrate into daily dev workflow. Should probably break it into detection, documentation, analysis, and action phases. Tools matter: static analysis for dead code, issue trackers for decisions, and visualization for dependencies.
User probably cares about scalability and low friction. Emphasize automation where possible (e.g., CI hooks) but keep human context in the loop. The consolidation opportunities part hints at cost-saving motives—maybe they're optimizing cloud costs or onboarding new teams. Should include metrics to track ROI.
Also, "pipeline" suggests they want something iterative, not a big bang. Maybe structure it like a feedback loop: detect → document → analyze → decide → act → measure. Need to warn about over-engineering—archeology shouldn't become another bureaucratic layer. Keep it pragmatic.
Codebase Archaeology Pipeline: Continuous Discovery & Consolidation
Overview
A lightweight, automated pipeline that continuously uncovers technical debt, historical decisions, and consolidation opportunities without disrupting development velocity.
Phase 1: Automated Discovery (Continuous)
1.1 Dead Code Detection
- Static Analysis:
- Tools:
TS/JS → ts-unused-exports, depcheck; Java → SonarQube dead code; Python → vulture
- CI Integration: Run nightly scans, flag unused imports/exports/functions/classes
- Runtime Coverage:
- Combine
codecov/jacoco reports with static analysis
- Rule: "Code not touched in 6 months AND <1% test coverage" → Candidate
- API Endpoint Monitoring:
- Track request logs → Flag endpoints with zero traffic in 90 days
- Tooling: Custom middleware + analytics pipeline
1.2 Historical Decision Mining
- Git Archaeology:
- Parse commit messages for patterns:
[ARCH], [DEPRECATE], [REFACTOR], FIXME, HACK
- Extract PR descriptions mentioning "temporary", "quick fix", "until X", "workaround"
- Tool:
git log --grep + custom parser, store in searchable DB
- Issue Tracker Integration:
- Scrape Jira/GitHub Issues for labels:
technical-debt, debt, refactor-needed
- Link issues to code locations via
blame/git grep
- Architecture Decision Records (ADR):
- Enforce ADR storage in
/docs/adr/
- Parse ADRs for "status: superseded" → flag related code
1.3 Dependency & Pattern Detection
- Duplication Detection:
jscpd/pmd-cpd → 10+ line duplicates across modules
- Stranded Modules:
- Dependency graph analysis (using
madge/depcruise)
- Flag modules with no dependents AND no dependencies (orphaned)
- Technology Stack Mapping:
- Scan for multiple logging libraries, HTTP clients, ORMs doing same thing
Phase 2: Curation & Context (Human-in-the-Loop)
2.1 Auto-Generated Tickets
[ARCHEOLOGY Finding] - [Type: Dead Code/Historical Debt/Duplication]
Location: src/moduleX/serviceY.js:45-67
Discovery: Unused function `processData()`
Context:
- Last touched: 14 months ago (commit abc123)
- Original ADR: #42 (2019) - "Quick hack for legacy export"
- Current alternatives: src/utils/dataProcessor.js
Confidence: 92% (based on 0 runtime references + 6 months no coverage)
Suggested Action: [Deprecate] [Remove] [Document]
2.2 Central Dashboard
- Tool: Custom Grafana dashboard/static site
- Views:
- Debt Heatmap: File-level "rot" score (age × complexity × churn)
- Decision Timeline: Chronological view of key architectural pivots
- Consolidation Opportunities: List of 2+ similar components (e.g., 3 different auth adapters)
- Filters: By team, module, risk level
2.3 Regular Triage Meetings
- Frequency: Bi-weekly 30-minute "Archaeology Sync"
- Attendees: Tech leads + rotating senior engineers
- Agenda:
- Review top 5 findings (by impact/confidence)
- Assign owners for investigation
- Vote on consolidation projects (add to roadmap)
Phase 3: Action & Consolidation
3.1 Standardized Removal Process
deprecation_workflow:
- Announce in #architecture channel + ADR update
- Add deprecation warning (runtime log) for 2 sprints
- Create "removal" PR linked to archaeology ticket
- Verify via integration tests + canary deployment
- Delete after 4 weeks if no alerts
3.2 Consolidation Projects
- Pattern: "Replace Component A + Component B with Shared Library C"
- Approval: Requires:
- Cost analysis (maintenance hours saved)
- Migration plan (with feature flags)
- Backcompat strategy
- Tracking: Dedicated epic in project management tool
3.3 Knowledge Preservation
- Annotate Code: Encourage
// ARCH-NOTE: ... comments for intentional complexity
- Living ADRs: Update existing ADRs when consolidation happens
- Exit Interviews: Document reasons when senior engineers leave
Phase 4: Feedback & Metrics
4.1 Key Metrics
| Metric | Target | Measurement |
|---|
| Dead Code Ratio | <5% of codebase | (Unused code / total) |
| Decision Latency | <30 days | (Issue created → ADR updated) |
| Consolidation ROI | >2:1 | (Hours saved / consolidation cost) |
| Archaeology Adoption | >70% of teams | (Teams triaging tickets) |
4.2 Success Signals
- ✅ Fewer "what is this?" questions in PR reviews
- ✅ Reduced cognitive load scores from developer surveys
- ✅ Faster onboarding time for new engineers
- ✅ Decreased bug rate in legacy modules
Toolchain Recommendations
| Function | OSS Tools | Enterprise Alternatives |
|---|
| Static Analysis | sonarqube, codeclimate | SonarQube Enterprise |
| Dependency Mapping | madge, depcheck | Snyk, WhiteSource |
| Coverage | Istanbul, jacoco | Codecov, SonarCloud |
| Dashboard | Grafana + PostgreSQL | Datadog, New Relic |
| Ticketing | GitHub Issues + Projects | Jira + Advanced Roadmaps |
Anti-Patterns to Avoid
- ❌ Over-automation: Don't auto-delete—human judgment required
- ❌ Archaeology as Punishment: Frame as "cleaner foundation," not "cleaning up mess"
- ❌ Ignoring Context: Some "dead code" is hacky but critical (e.g.,災害復旧手順)
- ❌ One-Time Audit: Must be continuous, not a big-bang cleanup
Getting Started (Week 1)
- Run
depcheck/ts-unused-exports on one microservice
- Generate top 10 dead functions, create tickets
- Schedule first triage meeting with 3 volunteers
- Add archaeology label to issue tracker
- Set up nightly scan cron job with report to Slack
Core Philosophy: Make the invisible visible, but only act on what matters. This pipeline turns archaeological curiosity into actionable consolidation, reducing entropy while preserving necessary complexity. Start small, validate with one team, then scale.