feat(build): embed general.md into AGENTS.md, not just CLAUDE.md

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Julian lechnerandClaude Sonnet 5 committed 2026-09-16 15:42:36 +02:00
1 parent 3a01d28506
commit 3fa0d74ad8
2 files changed
+17 -11

No files matched your search

+9 -5
View File
@@ -90,10 +90,11 @@ foreach ($agentDir in $sourceAgentDirs) {
$agentNames += $name $agentNames += $name
} }
# Codex keeps the original rule-loading text unchanged: every rule ships as a plain # Codex: general.md is embedded directly into AGENTS.md, the same way Claude embeds
# file and AGENTS.md tells Codex to load the matching one by path. # it into CLAUDE.md, instead of only being referenced by path — guaranteed present
# either way, and safe even if a subagent's AGENTS.md inheritance is not guaranteed.
$codexRuleLoading = @' $codexRuleLoading = @'
Always load and apply `rules/general.md` before starting any task. General rules are embedded below.
When programming, always load and apply `rules/security.md`. This includes implementing, modifying, debugging, reviewing, testing, and configuring software, scripts, hooks, infrastructure, and integrations. When programming, always load and apply `rules/security.md`. This includes implementing, modifying, debugging, reviewing, testing, and configuring software, scripts, hooks, infrastructure, and integrations.
@@ -157,9 +158,12 @@ foreach ($platform in @('windows','linux')) {
$claudeRuleLoading = "Always apply ``rules/general.md`` before starting any task, embedded below.`r`n`r`nDetect the languages, frameworks, tools, and change areas from the repository and the requested work. Invoke every matching rule skill before editing. Invoke all matching rule skills when multiple technologies apply.`r`n`r`nInvoke rule skills when their subject applies:`r`n`r`n" + ($claudeRuleSkillLines -join "`r`n") $claudeRuleLoading = "Always apply ``rules/general.md`` before starting any task, embedded below.`r`n`r`nDetect the languages, frameworks, tools, and change areas from the repository and the requested work. Invoke every matching rule skill before editing. Invoke all matching rule skills when multiple technologies apply.`r`n`r`nInvoke rule skills when their subject applies:`r`n`r`n" + ($claudeRuleSkillLines -join "`r`n")
$sharedTemplate = Get-Content (Join-Path $shared 'global-instructions.md') -Raw $sharedTemplate = Get-Content (Join-Path $shared 'global-instructions.md') -Raw
Set-Content (Join-Path $output "codex-$platform/AGENTS.md") ($sharedTemplate.Replace('__RULE_LOADING__', $codexRuleLoading)) -Encoding UTF8
$generalContent = Get-Content (Join-Path $shared 'rules/general.md') -Raw $generalContent = Get-Content (Join-Path $shared 'rules/general.md') -Raw
$agentsContent = $sharedTemplate.Replace('__RULE_LOADING__', $codexRuleLoading)
$agentsContent = $agentsContent.TrimEnd() + "`r`n`r`n---`r`n`r`n$generalContent"
Set-Content (Join-Path $output "codex-$platform/AGENTS.md") $agentsContent -Encoding UTF8
$claudeContent = $sharedTemplate.Replace('__RULE_LOADING__', $claudeRuleLoading) $claudeContent = $sharedTemplate.Replace('__RULE_LOADING__', $claudeRuleLoading)
$claudeContent = $claudeContent.TrimEnd() + "`r`n`r`n---`r`n`r`n$generalContent" $claudeContent = $claudeContent.TrimEnd() + "`r`n`r`n---`r`n`r`n$generalContent"
Set-Content (Join-Path $output "claude-$platform/CLAUDE.md") $claudeContent -Encoding UTF8 Set-Content (Join-Path $output "claude-$platform/CLAUDE.md") $claudeContent -Encoding UTF8
+8 -6
View File
@@ -80,10 +80,11 @@ for agent_dir in "${agent_dirs[@]}"; do
agent_seen[$name]=1 agent_seen[$name]=1
done done
# Codex keeps the original rule-loading text unchanged: every rule ships as a plain # Codex: general.md is embedded directly into AGENTS.md, the same way Claude embeds
# file and AGENTS.md tells Codex to load the matching one by path. # it into CLAUDE.md, instead of only being referenced by path — guaranteed present
# either way, and safe even if a subagent's AGENTS.md inheritance is not guaranteed.
read -r -d '' codex_rule_loading <<'BLOCK' || true read -r -d '' codex_rule_loading <<'BLOCK' || true
Always load and apply `rules/general.md` before starting any task. General rules are embedded below.
When programming, always load and apply `rules/security.md`. This includes implementing, modifying, debugging, reviewing, testing, and configuring software, scripts, hooks, infrastructure, and integrations. When programming, always load and apply `rules/security.md`. This includes implementing, modifying, debugging, reviewing, testing, and configuring software, scripts, hooks, infrastructure, and integrations.
@@ -152,10 +153,11 @@ Invoke rule skills when their subject applies:
${claude_rule_loading_list%$'\n'}" ${claude_rule_loading_list%$'\n'}"
shared_template=$(<"$shared/global-instructions.md") shared_template=$(<"$shared/global-instructions.md")
agents_content=${shared_template//__RULE_LOADING__/$codex_rule_loading}
printf '%s\n' "$agents_content" > "$output/codex-$platform/AGENTS.md"
general_content=$(<"$shared/rules/general.md") general_content=$(<"$shared/rules/general.md")
agents_content=${shared_template//__RULE_LOADING__/$codex_rule_loading}
printf '%s\n\n---\n\n%s\n' "${agents_content%$'\n'}" "$general_content" > "$output/codex-$platform/AGENTS.md"
claude_content=${shared_template//__RULE_LOADING__/$claude_rule_loading} claude_content=${shared_template//__RULE_LOADING__/$claude_rule_loading}
printf '%s\n\n---\n\n%s\n' "${claude_content%$'\n'}" "$general_content" > "$output/claude-$platform/CLAUDE.md" printf '%s\n\n---\n\n%s\n' "${claude_content%$'\n'}" "$general_content" > "$output/claude-$platform/CLAUDE.md"