Description
Issue Type: Bug
Environment:
- OS: Linux (WSL2)
- Shell: bash
- spec-kit version: Latest (as of 2025-09-16)
Description:
The update-agent-context.sh script in .specify/scripts/bash/ contains several critical bugs that prevent it from working correctly:
Problems Identified:
- Sed Regular Expression Errors:
sed: -e expression Add John Lam as contributor and release badge #1, char 28: Invalid preceding regular expression
sed: -e expression Add John Lam as contributor and release badge #1, char 31: Invalid preceding regular expression
sed: -e expression Add John Lam as contributor and release badge #1, char 18: Invalid preceding regular expression
sed: -e expression Add John Lam as contributor and release badge #1, char 23: Invalid preceding regular expression - Incorrect Template Path:
- Script tries to copy from /templates/agent-file-template.md (line 16)
- Correct path should be /.specify/templates/agent-file-template.md - Field Extraction Issues:
- Field names containing forward slashes (like "Language/Version") break sed patterns
- Markdown formatting with asterisks (Field:) causes regex parsing failures
Error Context:
The script fails when trying to:
- Extract information from plan.md files using grep/sed combinations
- Perform template placeholder substitutions
- Handle field names with special characters
Steps to Reproduce:
- Initialize a spec-kit project: specify init test-project
- Create a feature with /specify command
- Run /plan command to generate plan.md
- Execute: .specify/scripts/bash/update-agent-context.sh claude
- Observe sed expression errors and missing template file error
Expected Behavior:
- Script should extract field values from plan.md correctly
- Script should create/update agent context files (CLAUDE.md, GEMINI.md, etc.)
- Template substitutions should work without regex errors
Suggested Fix:
The core issues stem from using complex sed operations with unescaped special characters. A more robust approach would be to:
- Fix the template path reference
- Use Python-based text processing instead of sed for complex field extraction
- Implement proper escaping for special regex characters
Impact:
This affects the /plan command's ability to automatically update agent context files, which is part of the core spec-kit workflow for maintaining agent-specific information.
Additional Context:
The script appears to be attempting to maintain agent context files with current project information extracted from feature plans, but the implementation has reliability issues
with text processing that cause it to fail on common field names and template operations.
This issue prevents the automated agent context updates that are part of the spec-driven development workflow, requiring manual intervention to maintain agent files.
Activity
sosaurizar commentedon Sep 17, 2025
same error on ubuntu,
Shell: bash
spec-kit version: Latest (as of 2025-09-16)
miklschmidt commentedon Sep 22, 2025
I had GPT-5 fix mine, it was broken in so many ways that i didn't want to waste time on fixing it manually. Try this:
`scripts/bash/update-agent-context.sh`
Agent Context Updates Summary:
fields load without regex errors; see .specify/scripts/bash/update-agent-context.sh:141-157.
techs, structure, commands, recent change) and to escape the triple backticks correctly;
see .specify/scripts/bash/update-agent-context.sh:239-324.
entries for the current branch, and preserves downstream headings (.specify/scripts/bash/
update-agent-context.sh:327-419), while update_recent_changes dedupes the newest entry before
appending (.specify/scripts/bash/update-agent-context.sh:423-493).
attempting incremental edits (.specify/scripts/bash/update-agent-context.sh:583-619).
Resulting AGENTS Context
reminder preserved under the guarded block (AGENTS.md:1-27).
Ran .specify/scripts/bash/update-agent-context.sh after the fixes; it now completes cleanly
and produces the updated AGENTS.md. No automated tests were executed.
github-actions commentedon Apr 3, 2026
This issue has been automatically marked as stale because it has not had any activity for 150 days. It will be closed in 30 days if no further activity occurs.
fix(bash): sed replacement escaping, BSD portability, dead cleanup code
fix(bash): sed replacement escaping, BSD portability, dead cleanup code
fix(bash): sed replacement escaping, BSD portability, dead cleanup code
fix(bash): sed replacement escaping, BSD portability, dead cleanup code
fix(bash): sed replacement escaping, BSD portability, dead cleanup in…
fix(bash): sed replacement escaping, BSD portability, dead cleanup in…
fix(bash): sed replacement escaping, BSD portability, dead cleanup in…
fix(bash): sed replacement escaping, BSD portability, dead cleanup in…