원클릭으로
titan-forge
Execute the sync.json plan — refactor code, validate with /titan-gate, commit, and advance state (Titan Paradigm Phase 4)
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Execute the sync.json plan — refactor code, validate with /titan-gate, commit, and advance state (Titan Paradigm Phase 4)
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
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
| name | titan-forge |
| description | Execute the sync.json plan — refactor code, validate with /titan-gate, commit, and advance state (Titan Paradigm Phase 4) |
| argument-hint | <--phase N> <--target name> <--dry-run> <--yes> |
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep, Skill, Agent |
You are running the FORGE phase of the Titan Paradigm.
Your goal: read sync.json, find the next incomplete execution phase, make the actual code changes for each target, validate with /titan-gate, commit, and advance state.
Context budget: One phase per invocation. Do not attempt all phases in one session — the context window will fill. Run one phase, report, stop. User re-runs for the next phase.
Arguments (from $ARGUMENTS):
--phase N → jump to specific phase--target <name> → run single target only (for retrying failures)--dry-run → show what would be done without changing code--yes → skip confirmation prompt (typically passed by /titan-run orchestrator)Worktree check:
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-forge."
Load artifacts. Read:
.codegraph/titan/sync.json — execution plan (if missing: "Run /titan-sync first.").codegraph/titan/titan-state.json — current state.codegraph/titan/gauntlet.ndjson — per-target audit details.codegraph/titan/gauntlet-summary.json — aggregated resultsValidate state. If titan-state.json has currentPhase other than "sync" and no existing execution block, stop: "State not ready. Run /titan-sync first."
Initialize execution state (if first run). Add to titan-state.json:
{
"execution": {
"currentPhase": 1,
"completedPhases": [],
"currentTarget": null,
"completedTargets": [],
"failedTargets": [],
"commits": [],
"currentSubphase": null,
"completedSubphases": [],
"diffWarnings": []
}
}
Determine next phase. Use --phase N if provided, otherwise find the lowest phase number not in completedPhases.
Print plan:
Phase N: <label> — N targets, estimated N commits
Ask for confirmation before starting (unless $ARGUMENTS contains --yes).
Each phase type requires different code-change logic:
codegraph fn-impact <target> -T --jsoncodegraph exports <file> -T --jsoncatch {} with catch (e) { logger.debug(...) } or explicit fallbackwalkXNode switch cases into handler functionsFor each target in the current phase:
Skip if done. Check if target is already in execution.completedTargets. If so, skip.
Update state. Set execution.currentTarget in titan-state.json.
Read gauntlet entry. Find this target in gauntlet.ndjson → get recommendation, violations, metrics.
Understand before touching. Run codegraph commands:
codegraph context <target> -T --json
If blast radius > 0:
codegraph fn-impact <target> -T --json
Check if already fixed. If the file has changed since gauntlet ran, re-check metrics:
codegraph complexity --file <file> --health -T --json
If the target now passes all thresholds, skip with note: "Target already passes — skipping."
Read source file(s). Understand the code before editing.
Apply the change based on phase strategy (Step 1) + gauntlet recommendation.
Stage changed files:
git add <specific changed files>
Diff review (intent verification): Before running gate or tests, verify the diff matches the intent. This catches cases where the code change is structurally valid but doesn't match what was planned.
Collect the context:
git diff --cached --stat
git diff --cached
Load the gauntlet entry for this target (from gauntlet.ndjson) and the sync plan entry (from sync.json → executionOrder.find(e => e.phase === currentPhase)).
Check all of the following:
D1. Scope — only planned files touched:
Compare staged file paths against sync.json → executionOrder.find(e => e.phase === currentPhase).targets and their known file paths (from gauntlet entries). Flag any file NOT associated with the current target or phase.
D2. Intent match — diff aligns with gauntlet recommendation:
First, check if this target is a dead-code target (present in titan-state.json → roles.deadSymbols). If so, the expected recommendation is "remove dead code" — skip gauntlet entry lookup (dead-code targets have no gauntlet.ndjson entry) and verify the diff shows only deletions (no new functions or logic added). If the diff contains non-trivial additions for a dead-code target → DIFF FAIL.
Otherwise, read the gauntlet entry's recommendation field and violations list. Verify the diff addresses them:
D3. Commit message accuracy:
Compare the planned commit message from sync.json against what the diff actually does.
D4. Deletion audit: If the diff deletes code (lines removed > 10), identify deleted symbols by comparing the pre-change file against removed lines:
# Get the pre-change version's symbols (temp file for shell portability)
D4_PRE_EXT="${changed_file##*.}"
D4_PRE_TMP=$(mktemp "/tmp/titan-d4-pre-XXXXXX.${D4_PRE_EXT}")
git show HEAD:<changed-file> > "$D4_PRE_TMP"
codegraph where --file "$D4_PRE_TMP" -T --json 2>/dev/null
rm -f "$D4_PRE_TMP"
Cross-reference with git diff --cached -- <changed-file> to find symbols whose definitions appear only in removed lines (lines starting with -). For each deleted symbol:
codegraph fn-impact <deleted-symbol> -T --json 2>/dev/null
If the deleted symbol has active callers not updated in this diff → DIFF FAIL: "Deleted still has callers not updated in this commit."
D5. Leftover check: If the gauntlet recommendation mentioned specific symbols to remove/refactor, verify they were actually addressed:
<symbol> for removal but it was not deleted."<symbol> but original function was not simplified."On DIFF FAIL:
git reset HEAD -- $(git diff --cached --name-only)
git checkout -- $(git diff --name-only)
Add to execution.failedTargets with reason starting with "diff-review: ". Continue to next target.
On DIFF WARN: Log the warning but proceed to gate. Include the warning in the gate-log entry.
Run tests — detect the project's test command from package.json (same detection as gate Step 4):
testCmd=$(node -e "const p=require('./package.json');const s=p.scripts||{};const script=s.test?'test':s['test:ci']?'test:ci':null;if(!script){console.log('NO_TEST_SCRIPT');process.exit(0);}const fs=require('fs');const runner=fs.existsSync('yarn.lock')?'yarn':fs.existsSync('pnpm-lock.yaml')?'pnpm':fs.existsSync('bun.lockb')?'bun':'npm';console.log(runner+(script==='test'?' test':' run '+script));")
testCmd == "NO_TEST_SCRIPT" → skip pre-gate test run (no test script configured).$testCmd 2>&1
If tests fail → go to rollback (step 13).Note: Gate (Step 11) also runs tests. This pre-gate test is a fast-fail optimization — it catches obvious breakage before running the full gate checks (codegraph analysis, semantic assertions, arch snapshot). For projects with fast test suites the duplication is negligible; for slow suites, the tradeoff is: catch failures ~2x faster at the cost of ~2x test time on passing targets.
Run /titan-gate:
Use the Skill tool to invoke titan-gate.
--cycles flag — treat that the same as Step 2) → go to rollback (step 13) to also revert working tree.git reset HEAD -- $(git diff --cached --name-only) && git checkout -- $(git diff --name-only), add to execution.failedTargets with reason, log the gate report, and continue to the next target. Do NOT go to step 13 — that step is for Step 2/4 failures where gate already unstaged; going there again would attempt a duplicate rollback.On success:
git commit -m "<commit message from sync.json>"
execution.commitsexecution.completedTargetsexecution.diffWarnings (if any). Each entry must follow this schema:
{ "target": "<target-name>", "check": "<D3 or D5>", "message": "<warning text>", "phase": N }
titan-state.jsonOn failure (test or gate):
# Discover dirty files at rollback time (don't rely on carried file list)
git reset HEAD -- $(git diff --cached --name-only)
git checkout -- $(git diff --name-only)
execution.failedTargets with reason: { "target": "<name>", "reason": "<why>", "phase": N }execution.currentTargetWhen all targets in the phase are processed:
execution.completedPhasesexecution.currentPhase to the next phase numberexecution.currentTargettitan-state.jsonPrint:
## Phase N Complete: <label>
Targets: X/Y completed, Z failed
Commits: N
Files changed: N
### Failed targets (if any):
- <target>: <reason>
### Next: Phase M — <label> (N targets)
Run /titan-forge to continue.
If all phases are complete:
## All phases complete
Total commits: N
Total targets: X completed, Y failed
Failed targets: <list or "none">
Run /titan-gate on the full branch to validate.
execution.currentTarget. Already-committed targets are skipped.--dry-run: Walk through all targets, print what would be done (phase strategy, gauntlet recommendation, files affected), but make no changes.--target <name>: Run only that target. Useful for retrying entries in failedTargets.--json and -T for codegraph commands./titan-gate. No exceptions.sync.json.git add . or git add -A.git reset HEAD -- $(git diff --cached --name-only) to unstage, then git checkout -- $(git diff --name-only) to revert working tree. Never git reset --hard./titan-gate. Even for "trivial" changes.| Skill | Produces | Used by /titan-forge |
|---|---|---|
/titan-recon | titan-state.json, GLOBAL_ARCH.md | State tracking, domain context |
/titan-gauntlet | gauntlet.ndjson, gauntlet-summary.json | Per-target recommendations |
/titan-sync | sync.json | Execution plan (phases, targets, commits) |
/titan-gate | Gate verdict | Called per-commit for validation |
/titan-reset | Clean slate | Removes all artifacts |
This skill lives at .claude/skills/titan-forge/SKILL.md. Edit if phase strategies need refinement or execution loop needs adjustment after dogfooding.