Always include user instruction in every run#56
Conversation
- Rename STYLE_GUIDE_FILENAME to USER_INSTRUCTION_FILENAME in constants - Create user-instruction-loader.ts to replace style-guide-loader.ts - Update all imports and variable names across codebase - Remove unnecessary prompt body for VECTORLINT.md evaluation - VECTORLINT.md content now used directly from system prompt
- Rewrite directive with structured Role/Task/Instructions format - Remove redundant INSTRUCTION sections from bundled presets - Style guide now runs alongside rules (not fallback-only) - Fix zero-config test expectation for empty runRules array - Remove obsolete AGENTS.md architectural document
📝 WalkthroughWalkthroughThis PR systematically replaces the style-guide system with a user-instruction system throughout the codebase. It removes zero-config behavior, eliminates the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/style-guide/zero-config.test.ts (1)
6-37:⚠️ Potential issue | 🟠 MajorFix zero-config test: STYLE_GUIDE_FILENAME is removed (runtime failure).
STYLE_GUIDE_FILENAMEis no longer exported, so it’sundefinedat runtime and causes the observed “path argument must be a string” failures. Switch toUSER_INSTRUCTION_FILENAMEin the import and usage.🛠️ Suggested fix
-import { DEFAULT_CONFIG_FILENAME, STYLE_GUIDE_FILENAME } from '../../src/config/constants'; +import { DEFAULT_CONFIG_FILENAME, USER_INSTRUCTION_FILENAME } from '../../src/config/constants'; @@ - // Create only the style guide - writeFileSync(path.join(tempDir, STYLE_GUIDE_FILENAME), '# My Style Guide'); + // Create only the user instructions + writeFileSync(path.join(tempDir, USER_INSTRUCTION_FILENAME), '# My Instructions'); @@ - writeFileSync(path.join(tempDir, STYLE_GUIDE_FILENAME), '# My Style Guide'); + writeFileSync(path.join(tempDir, USER_INSTRUCTION_FILENAME), '# My Instructions');
🧹 Nitpick comments (4)
src/cli/orchestrator.ts (2)
805-817: Consider scoping “always-run” to the user-instruction prompt only.Right now any prompt with
pack === ''bypasses RunRules. If the intent is to always run onlyVECTORLINT.md, consider narrowing the condition to avoid future empty-pack prompts unintentionally running for every file.♻️ Possible tightening
- if (p.pack === '') return true; + if (p.pack === '' && p.filename === USER_INSTRUCTION_FILENAME) return true;
825-840: Align comment with behavior (user instruction runs whenever provided).The code injects the prompt whenever
userInstructionContentis set, not only when no rules match. Update the comment (or add a guard) to reflect the actual behavior.📝 Comment tweak
- // If no rules matched but VECTORLINT.md exists, run an evaluation using it. - // The LLM will use the VECTORLINT.md content from the system prompt. + // Run user-instruction evaluation alongside matched rules when VECTORLINT.md is provided. + // The LLM uses the VECTORLINT.md content from the system prompt.src/boundaries/user-instruction-loader.ts (2)
1-61: Indentation uses 4 spaces instead of 2.The coding guidelines specify 2-space indentation, but this file uses 4-space indentation throughout. As per coding guidelines: "Use 2-space indentation; avoid trailing whitespace".
🔧 Suggested fix to use 2-space indentation
export interface UserInstructionResult { - content: string | null; - tokenEstimate: number; - path: string | null; + content: string | null; + tokenEstimate: number; + path: string | null; }Apply similar 4→2 space changes throughout the file.
15-17: Defensive null check is redundant given the type signature.The function signature declares
text: string, but the implementation usestext?.length ?? 0which guards against null/undefined. In strict TypeScript, astringparameter cannot be null or undefined. Consider either:
- Removing the defensive check since the type guarantees a string
- Changing the signature to
text: string | null | undefinedif null inputs are expectedOption 1: Simplify to match type signature
export function estimateTokens(text: string): number { - return Math.ceil((text?.length ?? 0) / 4); + return Math.ceil(text.length / 4); }
- Replace STYLE_GUIDE_FILENAME with USER_INSTRUCTION_FILENAME - Update template content expectations to use 'User Instructions' - Fix request-builder directive order test expectation
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/request-builder.test.ts`:
- Around line 5-9: The test description is inaccurate:
DefaultRequestBuilder.buildPromptBodyForStructured actually prepends the
directive before the structured body, so change the test title to reflect that
behavior (e.g., "prepends directive to structured prompts without extra builder
text") and leave the assertion expect(out).toBe('DIR\n\nP') unchanged; update
only the string description in the it(...) call.
🧹 Nitpick comments (2)
tests/style-guide/zero-config.test.ts (1)
21-23: Stale comment refers to "style guide" instead of "user instruction".The comment on line 22 still says "Create only the style guide" but the file being created is now the user instruction file (
USER_INSTRUCTION_FILENAME). Consider updating for consistency:- // Create only the style guide + // Create only the user instruction filetests/style-guide/init-command.test.ts (1)
74-76: Stale comment refers to "style guide" instead of "user instruction".- // Create a pre-existing style guide + // Create a pre-existing user instruction file
- Fix request-builder test description: 'appends' → 'prepends' - Update CLAUDE.md terminology: 'Style Guide' → 'User Instructions' - Remove 'Security & Configuration Tips' section from CLAUDE.md
- Resolved conflict in directive-loader.ts by prioritizing simple_zeroconfig - Added fix field instruction from main as item #10
* refactor: rename style guide to user instructions - Rename STYLE_GUIDE_FILENAME to USER_INSTRUCTION_FILENAME in constants - Create user-instruction-loader.ts to replace style-guide-loader.ts - Update all imports and variable names across codebase - Remove unnecessary prompt body for VECTORLINT.md evaluation - VECTORLINT.md content now used directly from system prompt * refactor: centralize evaluation instructions in directive - Rewrite directive with structured Role/Task/Instructions format - Remove redundant INSTRUCTION sections from bundled presets - Style guide now runs alongside rules (not fallback-only) - Fix zero-config test expectation for empty runRules array - Remove obsolete AGENTS.md architectural document * test: fix imports and expectations after terminology refactor - Replace STYLE_GUIDE_FILENAME with USER_INSTRUCTION_FILENAME - Update template content expectations to use 'User Instructions' - Fix request-builder directive order test expectation * docs: update test description and terminology in CLAUDE.md - Fix request-builder test description: 'appends' → 'prepends' - Update CLAUDE.md terminology: 'Style Guide' → 'User Instructions' - Remove 'Security & Configuration Tips' section from CLAUDE.md
Centralise Evaluation Instructions in Directive
Summary
Moves evaluation instructions from individual rule presets into a centralised directive, reducing duplication and simplifying prompt maintenance.
Problem
The previous approach had evaluation instructions duplicated across multiple files:
ai-pattern.md,pseudo-advice.md,repetition.md) contained its own## INSTRUCTIONsectionSolution
Centralised Directive — Rewrites the directive with a structured Role/Task/Instructions format that all rules share.
Simplified Presets — Removes redundant
## INSTRUCTIONsections from bundled presets. Rules now focus only on defining criteria.Style Guide Always Runs — Changes the style guide evaluation from fallback-only to always running alongside matched rules.
Changes
Breaking Changes
None. Output format remains backward compatible.
Summary by CodeRabbit
Release Notes