Preserve user content in agent config files on coldbox ai refresh#43
Conversation
Add COLDBOX-CLI:START/END markers to agent instruction templates so that `coldbox ai refresh` only updates the managed framework section while leaving user-authored documentation intact. - Add <!-- COLDBOX-CLI:START --> and <!-- COLDBOX-CLI:END --> markers to both agent-modern-instructions.md and agent-flat-instructions.md - Restructure templates: all managed content (guidelines, skills, MCP, project info) sits inside the markers; Custom Application Details moves to after the end marker with a note that it won't be overwritten - Add MANAGED_SECTION_START/END static constants to AgentRegistry.cfc - Add private mergeUserContent() helper that extracts the user section from an existing file and appends it to the refreshed managed section - Update configureAgent() to call mergeUserContent() for all agents (including AGENTS.md for Claude) instead of blindly overwriting Agent-Logs-Url: https://github.com/ColdBox/coldbox-cli/sessions/2b2dc668-9136-4fc3-9cec-b1d19209c61b Co-authored-by: lmajano <137111+lmajano@users.noreply.github.com>
coldbox ai refresh
|
@lmajano it appears to be working as expected. However, you might consider a more succinct default Agents.md file. I'm concerned that with such a large file, it's going to eat up people's context windows. I know this is is still an emerging standard, but in my research online I've seen recommendations averaging around ~300 lines. I've been solving this problem in my new apps by providing references to additional Agents.md files elsewhere in my application. For example, I have a section in my root Agents.md file that gives the LLM instructions on where to find more context on testing guidelines: Note how at the end, I point the LLM to additional information. You might consider something like this instead of listing out the entire manifest in a single file. For example: Just some food for thought. |
|
can you give me an example on our current approach. I believe I had left it lazy loaded, so it would read the other skils when needed |
|
Here's what a default Agents.md file looks like when you run Note that it's about 1000 lines long. If this were my template, I would consider trimming some of the generated reference/index sections, particularly:
Instead, I would replace it with a short section like this: |
coldbox ai refreshblindly overwrites agent config files (e.g.CLAUDE.md/AGENTS.md), destroying any user or AI-agent customizations on every run.Approach
Introduce
<!-- COLDBOX-CLI:START -->/<!-- COLDBOX-CLI:END -->demarcation markers in the generated files. On refresh, only the content between those markers is replaced; everything after the end marker is preserved.Changes
Templates (
agent-modern-instructions.md,agent-flat-instructions.md)COLDBOX-CLI:START/COLDBOX-CLI:ENDmarkersAgentRegistry.cfcMANAGED_SECTION_START/MANAGED_SECTION_ENDstatic constantsmergeUserContent(filePath, newContent)— extracts the user section from an existing file and re-appends it after the refreshed managed block:mergeUserContent()intoconfigureAgent()for all agent types (including Claude'sAGENTS.md)Example of resulting file structure:
⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.