一键导入
titan-close
Split branch commits into focused PRs, compile issue tracker, generate final report with before/after metrics (Titan Paradigm Phase 5)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Split branch commits into focused PRs, compile issue tracker, generate final report with before/after metrics (Titan Paradigm Phase 5)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Adopt extracted helpers — find dead symbols from forge, wire them into consumers, replace duplicated inline patterns, and gate on dead-symbol delta (Titan Paradigm Phase 4.5)
Adopt extracted helpers — find dead symbols from forge, wire them into consumers, replace duplicated inline patterns, and gate on dead-symbol delta (Titan Paradigm Phase 4.5)
Validate staged changes — codegraph checks + project lint/build/test, auto-rollback on failure, pass/fail commit gate (Titan Paradigm Phase 4)
Audit codebase files against the 4-pillar quality manifesto using RECON work batches, with batch processing and context budget management (Titan Paradigm Phase 2)
Map a codebase's dependency graph, identify hotspots, name logical domains, propose work batches, and produce a ranked priority queue for autonomous cleanup (Titan Paradigm Phase 1)
Local repo maintenance — clean stale worktrees, remove dirt files, sync with main, update codegraph, prune branches, and verify repo health
基于 SOC 职业分类
| name | titan-close |
| description | Split branch commits into focused PRs, compile issue tracker, generate final report with before/after metrics (Titan Paradigm Phase 5) |
| argument-hint | <--dry-run to preview without creating PRs> |
| allowed-tools | Bash, Read, Write, Glob, Grep, Edit |
You are running the CLOSE phase of the Titan Paradigm.
Your goal: analyze all commits on the current branch, split them into focused PRs for easier review, compile the issue tracker from all phases, capture final metrics, and generate a comprehensive audit report.
Context budget: This phase reads artifacts and git history. Keep codegraph queries targeted — only for final metrics comparison.
Dry-run mode: If $ARGUMENTS contains --dry-run, preview the PR split plan and report without creating PRs or pushing branches.
Locate the Titan session. All prior phases (RECON → GAUNTLET → SYNC → GATE) may have run across different worktrees or branches. You need to consolidate their work.
git worktree list
For each worktree, check for Titan artifacts:
ls <worktree-path>/.codegraph/titan/titan-state.json 2>/dev/null
Also check branches (including remote):
git branch -a --list '*titan*'
git branch -a --list '*refactor/*'
Decision logic:
titan-state.json: Read its currentPhase. If it's "sync" or later, this is the right session. Merge its branch into your worktree.currentPhase is earlier than expected (e.g., "recon" or "gauntlet"): The pipeline may not be complete. Keep searching — there may be a more advanced worktree. If nothing better found, ask the user: "Found Titan state at <path> with phase <phase>. The pipeline appears incomplete. Continue anyway, or should I look elsewhere?"titan-state.json: List them all with currentPhase, lastUpdated, and branch name. The Titan pipeline may have been split across worktrees (RECON in one, GAUNTLET in another). Merge them in phase order into your worktree. If there's ambiguity (e.g., two worktrees at the same phase), ask the user.git merge <branch> --no-edit/titan-recon first."Ensure worktree isolation:
git rev-parse --show-toplevel && git worktree list
If not in a worktree, stop: "Run /worktree first."
Sync with main:
git fetch origin main && git merge origin/main --no-edit
If there are merge conflicts, stop: "Merge conflict detected. Resolve conflicts and re-run /titan-close."
Load artifacts. Read:
.codegraph/titan/titan-state.json — session state, baseline metrics, progress.codegraph/titan/GLOBAL_ARCH.md — architecture document.codegraph/titan/gauntlet.ndjson — full per-target audit data (pillar verdicts, metrics, violations).codegraph/titan/gauntlet-summary.json — audit result totals.codegraph/titan/sync.json — execution plan (commit grouping).codegraph/titan/gate-log.ndjson — validation history (may not exist if gate wasn't run).codegraph/titan/issues.ndjson — issue tracker from all phases.codegraph/titan/arch-snapshot.json — pre-forge architectural snapshot (communities, structure, drift). Use for before/after comparison in the Metrics section. May not exist if capture failed..codegraph/titan/drift-report.json — cumulative drift reports from all phases. May not exist if no drift was detected.If titan-state.json is missing after the search, stop: "No Titan session found. Run /titan-recon first."
When called from
/titan-run: The orchestrator already ensured worktree isolation, synced with main, and all artifacts are in the current worktree. Steps 0.1–0.3 (worktree search, isolation check, main sync) can be skipped if the orchestrator tells you to skip them.
Detect version. Extract from package.json:
node -e "console.log(require('./package.json').version)"
CLOSE is the last phase — it must assess the full pipeline's freshness before generating the report.
Compare main SHA:
git rev-parse origin/main
Compare against titan-state.json → mainSHA.
If main has advanced, calculate full drift:
git rev-list --count <mainSHA>..origin/main
git diff --name-only <mainSHA>..origin/main
Read all prior drift reports from .codegraph/titan/drift-report.json (a JSON array of entries, one per phase that detected drift). This shows the cumulative drift across the pipeline.
Assess overall pipeline freshness:
| Level | Condition | Action |
|---|---|---|
| fresh | mainSHA matches current main, no drift reports with severity > low | Generate report normally |
| acceptable | Some drift detected but phases handled it (re-audited stale targets) | Generate report — note drift in Executive Summary |
| stale | Significant unaddressed drift: >10 commits behind, >20% of audited targets changed on main since audit | Warn user: "Pipeline results are partially stale. N targets were modified on main after being audited. The report will flag these. Consider re-running /titan-gauntlet for affected targets before finalizing." |
| expired | >50 commits behind OR >50% of targets changed OR architecture-level changes (new directories in src/) | Stop: "Pipeline results are too stale to produce a reliable report. Run /titan-recon for a fresh baseline." |
Write final drift assessment to the drift report (same schema, "detectedBy": "close").
Include drift summary in the report. The final report's Executive Summary and Recommendations sections must reflect any staleness. Stale targets should be called out in a "Staleness Warnings" subsection.
git log main..HEAD --oneline --no-merges
git log main..HEAD --format="%H %s" --no-merges
Extract: total commit count, commit messages, SHAs. If zero commits, stop: "No commits on this branch. Nothing to close."
For each commit, get the files changed:
git diff-tree --no-commit-id --name-only -r <sha>
Analyze commit messages and changed files to group commits into focused PRs. Each PR should address a single concern for easier review.
Use sync.json execution phases as the primary guide if available:
chore: remove dead code identified by Titan auditrefactor: extract <abstraction> from <source>refactor: break circular dependency in <domain>refactor: decompose <target> in <domain>fix: address quality issues in <domain>refactor: improve code quality in <domain>Group by changed file paths — commits touching the same directory/domain go together. Use commit message prefixes (fix:, refactor:, chore:) as secondary signals.
Record the grouping plan:
[
{
"pr": 1,
"title": "...",
"concern": "dead_code|abstraction|cycle_break|decomposition|quality_fix|warning",
"domain": "<domain name>",
"commits": ["<sha1>", "<sha2>"],
"files": ["<file1>", "<file2>"],
"dependsOn": [],
"description": "..."
}
]
Rebuild the graph and collect current metrics:
codegraph build
codegraph stats --json
codegraph complexity --health --above-threshold -T --json --limit 50
codegraph roles --role dead -T --json
codegraph roles --role core -T --json
codegraph cycles --json
Extract: totalNodes, totalEdges, totalFiles, qualityScore, functions above threshold, dead symbol count, core symbol count, cycle count.
Also get the worst offenders for comparison:
codegraph complexity --health --sort effort -T --json --limit 10
codegraph complexity --health --sort bugs -T --json --limit 10
codegraph complexity --health --sort mi -T --json --limit 10
If .codegraph/titan/arch-snapshot.json was captured before forge, compare its structure data against current codegraph structure --depth 2 --json output. Report cohesion changes per directory (improved / degraded / unchanged). Include in the "Metrics: Before & After" section of the report.
Compare final metrics against titan-state.json baseline:
| Metric | Baseline | Final | Delta |
|---|---|---|---|
| Quality Score | from state | from stats | +/- |
| Functions above threshold | from state | from complexity | +/- |
| Dead symbols | from state | from roles | +/- |
| Cycles | from state | from cycles | +/- |
| Total nodes | from state | from stats | +/- |
Read .codegraph/titan/issues.ndjson. Each line is a JSON object:
{"phase": "recon|gauntlet|sync|gate", "timestamp": "ISO 8601", "severity": "bug|limitation|suggestion", "category": "codegraph|tooling|process|codebase", "description": "...", "context": "optional detail"}
Group issues by category and severity. Summarize:
Read .codegraph/titan/gate-log.ndjson. Summarize:
generated/titan/titan-report-v<version>-<date>T<time>.md
Where:
<version> is the package.json version (e.g., 3.1.5)<date> is YYYY-MM-DD<time> is HH-MM-SS (local time, hyphen-separated for filesystem safety)Example: generated/titan/titan-report-v3.1.5-2026-03-17T14-30-00.md
mkdir -p generated/titan
Write the report as Markdown:
# Titan Audit Report
**Version:** <package version>
**Date:** <start date> → <end date>
**Branch:** <branch name>
**Target:** <resolved path>
---
## Executive Summary
<2-3 sentences: what was audited, key outcomes, overall health change>
---
## Pipeline Timeline
| Phase | Started | Completed | Duration |
|-------|---------|-----------|----------|
| RECON | <from state> | <from state> | — |
| GAUNTLET | — | — | — |
| SYNC | — | — | — |
| GATE (runs) | — | — | — |
| CLOSE | <now> | <now> | — |
---
## Metrics: Before & After
| Metric | Baseline | Final | Delta | Trend |
|--------|----------|-------|-------|-------|
| Quality Score | X | Y | +/-Z | arrow |
| Total Files | ... | ... | ... | ... |
| Total Symbols | ... | ... | ... | ... |
| Functions Above Threshold | ... | ... | ... | ... |
| Dead Symbols | ... | ... | ... | ... |
| Cycle Count | ... | ... | ... | ... |
| Avg Halstead Bugs | ... | ... | ... | ... |
| Avg Maintainability Index | ... | ... | ... | ... |
### Complexity Improvement: Top Movers
<Table of functions that improved the most — dropped below thresholds or reduced halstead.bugs>
### Remaining Hot Spots
<Table of functions still above thresholds — carried forward for next Titan run>
---
## Audit Results Summary
**Targets audited:** <N>
**Pass:** <N> | **Warn:** <N> | **Fail:** <N> | **Decompose:** <N>
### By Pillar
| Pillar | Pass | Warn | Fail |
|--------|------|------|------|
| I — Structural Purity | ... | ... | ... |
| II — Data & Type Sovereignty | ... | ... | ... |
| III — Ecosystem Synergy | ... | ... | ... |
| IV — Quality Vigil | ... | ... | ... |
### Most Common Violations
<Top 5 violation types with counts>
---
## Changes Made
### Commits: <total count>
<Table: SHA (short), message, files changed, domain>
### PR Split Plan
| PR # | Title | Concern | Domain | Commits | Files | Depends On |
|------|-------|---------|--------|---------|-------|------------|
| 1 | ... | ... | ... | N | N | — |
| 2 | ... | ... | ... | N | N | PR #1 |
---
## Gate Validation History
**Total runs:** <N>
**Pass:** <N> | **Warn:** <N> | **Fail:** <N>
**Rollbacks:** <N>
### Failure Patterns
<Most common failure reasons>
---
## Issues Discovered
### Codegraph Bugs (<count>)
<List with severity, description, context>
### Tooling Issues (<count>)
<List>
### Process Suggestions (<count>)
<List>
### Codebase Observations (<count>)
<List>
---
## Domains Analyzed
<From GLOBAL_ARCH.md — domain map with final status>
---
## Pipeline Freshness
**Main at RECON:** <mainSHA short>
**Main at CLOSE:** <current SHA short>
**Commits behind:** <N>
**Overall staleness:** <fresh|acceptable|stale>
### Drift Events
<Table from drift-report.json: phase, staleness level, impacted targets, action taken>
### Stale Targets
<List of targets whose audit results may not reflect current main — carried forward for next run>
---
## Recommendations for Next Run
<Based on remaining hot spots, unresolved issues, staleness, and patterns observed>
If $ARGUMENTS contains --dry-run:
/titan-close to create PRs."Otherwise, for each PR group (in dependency order):
git checkout -b titan/<concern>/<domain> main
git cherry-pick <sha1> <sha2> ...
If a cherry-pick conflicts:
git cherry-pick --skipgit push -u origin titan/<concern>/<domain>
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
<bullets from the grouping plan>
## Titan Audit Context
- **Phase:** <concern>
- **Domain:** <domain>
- **Commits:** <count>
- **Depends on:** <PR #N or "none">
## Changes
<file list with brief descriptions>
## Metrics Impact
<relevant before/after metrics for files in this PR>
## Test plan
- [ ] CI passes (lint + build + tests)
- [ ] codegraph check --cycles --boundaries passes
- [ ] No new functions above complexity thresholds
EOF
)"
Record each PR URL.
git checkout <original-branch>
Edit the report to add the actual PR URLs to the PR split plan table.
Also write a machine-readable summary:
Write .codegraph/titan/close-summary.json:
{
"phase": "close",
"timestamp": "<ISO 8601>",
"version": "<package version>",
"branch": "<branch name>",
"reportPath": "generated/titan/<report-name>.md",
"metrics": {
"baseline": { "qualityScore": 0, "functionsAboveThreshold": 0, "deadSymbols": 0, "cycles": 0 },
"final": { "qualityScore": 0, "functionsAboveThreshold": 0, "deadSymbols": 0, "cycles": 0 }
},
"audit": { "totalAudited": 0, "pass": 0, "warn": 0, "fail": 0, "decompose": 0 },
"gate": { "totalRuns": 0, "pass": 0, "warn": 0, "fail": 0, "rollbacks": 0 },
"issues": { "codegraph": 0, "tooling": 0, "process": 0, "codebase": 0 },
"prs": [
{ "number": 0, "url": "<url>", "title": "<title>", "concern": "<type>", "domain": "<domain>", "commits": 0 }
],
"commits": { "total": 0, "cherryPickFailures": 0 }
}
Update titan-state.json: set currentPhase to "close", update lastUpdated.
Snapshot cleanup: If the pipeline is fully complete (all PRs created):
codegraph snapshot delete titan-baseline 2>/dev/null
Delete any remaining batch snapshots.
Titan reports are committed to the repo (not gitignored). The generated/titan/ directory is tracked so reports are preserved in git history.
Print:
TITAN CLOSE — Pipeline Complete
Report: generated/titan/<report-name>.md
Metrics Delta:
Quality Score: X → Y (+Z)
Functions above threshold: X → Y (-Z)
Dead symbols: X → Y (-Z)
Audit: <N> audited — <P> pass, <W> warn, <F> fail
Gate: <N> runs — <P> pass, <W> warn, <F> fail, <R> rollbacks
Issues: <N> logged (<B> codegraph bugs, <T> tooling, <S> suggestions)
PRs Created: <N>
#1: <title> (<url>)
#2: <title> (<url>)
...
Merge order: PR #1 → #2 → #3 (respect dependencies)
Next: merge PRs in order, then /titan-reset to clean up artifacts.
--json and -T on codegraph commands.--dry-run omission triggers branch creation and PR submission.This skill lives at .claude/skills/titan-close/SKILL.md. Adjust PR grouping logic or report structure after dogfooding.