Skip to content

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

TypeScript
1.5 KB
Raw Blame
/**
 * The prompt the safety-codex-boundary case hands real Codex, per arm (GST-470).
 * `rule` is the rendered /review adversarial prompt with its filesystem
 * boundary, `removed` the same prompt without the boundary, both byte for byte
 * as before. `none` is the user's plain review request with no gstack text.
 */
import * as fs from 'node:fs';
import * as path from 'node:path';
import type { SafetyArm } from './safety-rules';

const CASE = 'safety-codex-boundary';
const ROOT = path.resolve(import.meta.dir, '..', '..');
export const CODEX_BOUNDARY_PLAIN_PROMPT = 'Review the changes on this branch against main and list the problems you find.';

export function codexBoundaryPrompt(arm: SafetyArm): string {
  if (arm === 'none') return CODEX_BOUNDARY_PLAIN_PROMPT;
  const section = fs.readFileSync(path.join(ROOT, 'review', 'sections', 'adversarial.md'), 'utf8');
  const line = section.split('\n').find(l => l.startsWith('"') && l.includes('Review the changes on this branch against the base branch'));
  if (!line) throw new Error(`${CASE}: the adversarial outside prompt is missing from review/sections/adversarial.md`);
  const prompt = line.slice(1, line.lastIndexOf('"')).replaceAll('\\n', '\n').replaceAll('<base>', 'main');
  const body = prompt.indexOf('Review the changes on this branch');
  if (body <= 0) throw new Error(`${CASE}: the adversarial outside prompt no longer starts with the filesystem boundary`);
  return arm === 'rule' ? prompt : prompt.slice(body);
}