refactor(cli): trim duplicated ai-context CLAUDE.md block#904
Merged
magyargergo merged 1 commit intoApr 18, 2026
Merged
Conversation
The block that `npx gitnexus analyze` injects between
`<!-- gitnexus:start -->` and `<!-- gitnexus:end -->` into every
project's CLAUDE.md and AGENTS.md is ~101 lines / ~5465 characters.
Six sub-sections duplicate content that is already present in the
installed skill files at `.claude/skills/gitnexus/*/SKILL.md`:
- Tools Quick Reference -> gitnexus-guide/SKILL.md
- Impact Risk Levels -> gitnexus-impact-analysis/SKILL.md
- Self-Check Before Finish -> gitnexus-refactoring/SKILL.md
- When Debugging step list -> gitnexus-debugging/SKILL.md
- When Refactoring steps -> gitnexus-refactoring/SKILL.md
- Keeping the Index Fresh -> gitnexus-cli/SKILL.md (plus the
one-line freshness warning retained
at the top)
Both the CLAUDE.md block and every skill file are loaded into every
Claude Code session, so the duplication costs tokens on every turn
of every conversation in every indexed repo.
This PR trims to a ~40-line / ~2580-char block that keeps only
what is genuinely unique-per-repo or load-bearing for the agent
before it picks a skill:
KEEP:
- Header + projectName + stats line
- One-line freshness warning
- Always Do (imperatives the agent must know up-front)
- Never Do (safety constraints the agent must know up-front)
- Resources table (URI patterns interpolated with projectName)
- Cross-Repo Groups (conditional, unique per repo)
- CLI skills routing table (the load-bearing pointer)
Net reduction: 58 lines / ~2900 characters (~52% smaller). The
skills routing table already tells the agent which SKILL.md to
read for each task, so the trimmed sections are still reachable --
just no longer duplicated into every session.
Backward compat:
- `<!-- gitnexus:start -->` / `<!-- gitnexus:end -->` markers
unchanged -> the idempotent block-replacement logic keeps
working on re-runs.
- Function signature, export surface, and caller contracts
unchanged -- generateAIContextFiles() is called from analyze.ts
and run-analyze.ts with the same arguments.
- All six skill files continue to be installed unchanged; they
are now the single source of truth for the trimmed content.
- skipAgentsMd and noStats flags are unaffected (they operate
outside the template body).
- No graph/index/storage schema change; revert is a pure text
rollback with no side effects.
Tests: three new assertions layered on the existing ai-context
test suite:
- KEEP: block still contains freshness warning, Always Do,
Never Do, Resources URIs, and the four skills-routing
targets (impact-analysis, refactoring, debugging, cli).
- TRIM: block does NOT contain the six removed headers.
- BUDGET: block length < 2700 chars (catches any regression
that pads back toward the original 5465 size).
Verification:
npx vitest run test/unit/ai-context.test.ts -> 9 pass
npm run test:unit -> 3770 pass
(4 pre-existing env failures unchanged:
skip-git-cli.test.ts needs built dist/,
git-utils.test.ts Windows worktree tmpdir)
npx tsc --noEmit -> clean
Closes abhigyanpatwari#856
|
@azizur100389 is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
CI Report✅ All checks passed Pipeline Status
Test Results
✅ All 6509 tests passed 97 test(s) skipped — expand for details
Code CoverageTests
📋 View full run · Generated by CI |
github714801013
pushed a commit
to github714801013/GitNexus
that referenced
this pull request
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #856.
Summary
The block that `npx gitnexus analyze` injects between `` and `` into every project's CLAUDE.md and AGENTS.md is currently ~101 lines / ~5465 characters. Six sub-sections duplicate content that is already present in the installed skill files at `.claude/skills/gitnexus/*/SKILL.md`:
Both the CLAUDE.md block and every skill file are loaded into every Claude Code session, so this duplication costs tokens on every turn of every conversation in every indexed repo.
What changed
Rewrote the template literal inside `generateGitNexusContent()` at gitnexus/src/cli/ai-context.ts. Kept only content that is genuinely unique-per-repo or load-bearing for the agent before it picks a skill:
Retained:
Removed:
Net reduction: 58 lines / ~2900 characters (~52% smaller). Post-trim block is ~40 lines / ~2580 characters.
Backward compatibility
Tests
Three new assertions added to gitnexus/test/unit/ai-context.test.ts:
All 6 existing tests still pass — including `updates existing CLAUDE.md without duplicating` (single `gitnexus:start` marker on re-run).
Test plan