| name | nazgul:context |
| description | Collect targeted codebase context for a specific objective type. Use before planning to deeply understand the code that will be affected. |
| context | fork |
| allowed-tools | Read, Write, Bash, Glob, Grep, LS |
| metadata | {"author":"Jose Mejia","version":"2.7.1"} |
Nazgul Context Collection
Examples
/nazgul:context — Collect context based on the current objective type
/nazgul:context refactor — Collect context specifically for a refactor scope
Current Project
- Profile: !
head -20 nazgul/context/project-profile.md 2>/dev/null || echo "No profile — run /nazgul:init first"
- Architecture: !
head -20 nazgul/context/architecture-map.md 2>/dev/null || echo "No architecture map"
Arguments
$ARGUMENTS
Instructions
Format all output per references/ui-brand.md — use stage banners, status symbols, and display patterns defined there.
Collect targeted context based on the objective type. Write results to nazgul/context/.
Determine Objective Type
Parse $ARGUMENTS (the ## Arguments block above) for an objective type — one of: refactor, bugfix, feature, greenfield, migration. If absent, derive it from nazgul/config.json classification (jq -r '.project.classification // empty' nazgul/config.json). Then collect the context section(s) matching that type, using the mapping below:
refactor → For Refactors
bugfix → For Bug Fixes
feature → For New Features
greenfield → For Greenfield
migration → treat as a refactor-style scope (For Refactors), focused on the data/system being migrated
For Refactors
- Identify ALL files in the refactor scope (use grep, glob)
- Map their imports/exports to find the full dependency tree
- Find ALL tests that cover these files
- Find ALL callers of functions/classes being refactored
- Check git blame for recent changes
- Read the actual code of every file in scope
- Document current behavior that must be preserved
- Write findings to
nazgul/context/refactor-scope.md
For Bug Fixes
- Trace the code path from entry point to error
- Find related tests (passing and failing)
- Check git log for recent changes to affected files
- Write findings to
nazgul/context/bugfix-scope.md
For New Features
- Find the most similar existing feature in the codebase
- Map its implementation pattern (routes, handlers, services, models, tests)
- Identify the extension points where the new feature integrates
- Document the pattern to follow
- Write findings to
nazgul/context/feature-scope.md
For Greenfield
- If project exists, scan for existing conventions
- If starting fresh, establish conventions based on tech stack
- Write findings to
nazgul/context/greenfield-scope.md
Every context collection MUST produce:
- A scope file listing every file that will be read or modified
- A "pattern reference" section showing how similar things are done
- A "risks" section identifying what could break
- A "test impact" section listing tests that must pass