As I planned in my previous post , I recently built the deterministic prompt generator for cxgrd.
How I built it
Just two steps:
1) Get the blast radius results from the subgraph
export interface PromptSubgraph {
changeDescription: string;
seedFiles: string[];
affectedFiles: Array<Pick<ImpactedFile,
'path' | 'severity' | 'reason' | 'distance' | 'impactType' | 'changeRequired' | 'suggestedFix'
>>;
dependencies: Array<{ from: string; to: string; type: string }>;
symbols: Record<string, string[]>;
architectureLayers: Record<string, string[]>;
riskLevel: string;
recommendations: string[];
}
2) Embed these results in the prompt
for (const file of subgraph.affectedFiles) {
if (subgraph.seedFiles.includes(file.path)) continue;
const distance = file.distance === 1 ? 'direct dependent' : `transitive dependent, depth ${file.distance}`;
const required = file.changeRequired ? 'review and update if the change requires it' : 'review for compatibility';
const layers = layerByFile.get(file.path);
const layerNote = layers?.length ? `; architecture layer: ${layers.join(', ')}` : '';
lines.push(
`- \`${file.path}\` — ${file.severity} risk, ${distance}; ${file.reason}; ${required}${layerNote}.`,
);
if (file.suggestedFix) lines.push(` Suggested action: ${file.suggestedFix}`);
}
[truncated]
It can't interpret the intent as clearly as an AI model, but it can definitely guide your agent's focus on important modules, so it won't break your project.
And this custom generator will also cut API costs for me.
Try cxgrd here. I would love to hear what your think about this, any form of feedback/suggestion is welcomed.
Github : https://github.com/cxgrd/cli
Top comments (1)
Deterministic prompt generation là hướng đi rất đúng khi muốn reproducibility cho code review automation. Với cxgrd, việc tách biệt prompt logic ra generator riêng giúp:
Một điểm cần lưu ý: deterministic không có nghĩa là rigid. Cân nhắc thêm prompt parameterization (ví dụ: severity threshold, language-specific rules, team conventions) để generator adapt được cho nhiều repo/context khác nhau mà vẫn giữ reproducibility.
Có thử benchmark token usage so với approach dynamic prompt chưa? Việc fixed template có thể tốn token hơn ở chỗ include toàn bộ context, nhưng trade-off lại là predictable cost và easier caching PS: the tool I meant is on labagent .tech