Skip to content

Support prompt references (@file.txt and $ls src) for modes and agents - #1317

Closed
mpazik wants to merge 1 commit into
anomalyco:devfrom
mpazik:support-references-in-prompts
Closed

Support prompt references (@file.txt and $ls src) for modes and agents#1317
mpazik wants to merge 1 commit into
anomalyco:devfrom
mpazik:support-references-in-prompts

Conversation

@mpazik

@mpazikmpazik commented Jul 25, 2025

Copy link
Copy Markdown

Support for file references @file.txt and bash execution $`bash command` in agent markdown and mode configuration.

These features allow more complex context loading.

More about the feature on anthropic docs

https://docs.anthropic.com/en/docs/claude-code/common-workflows#reference-files-and-directories
https://docs.anthropic.com/en/docs/claude-code/slash-commands#bash-command-execution

Implementation details

  • Lazy execution when mode and agent are invoked
  • Support nested include
  • Break on circular dependencies
  • Limit of 50000 tokens
  • Custom error when prompt resoultion failed

Missing

Notes

  • I had trouble providing a base directory for relative paths. My solution is not perfect as the path is included in the config schema, so users could possibly override it. An alternative was to have ConfigPriv with this extra path, but that would be overkill just for this single use case.
  • Not a big fan of the prompt resolution place. Ideally, it would be resolved for both modes and agents inside the session/index.ts, but we don't pass the agent. Possible solutions:
    • Specialized chat for mode and chat for agent variant of the chat method
    • Mode and agent unified so we don't need to pass both of them
  • Would be great to opt out from await SystemPrompt.custom() as sometimes it provides redundant or misleading information (I have agents that get custom dir structure)

@mpazik
mpazikforce-pushed the support-references-in-prompts branch from b89691d to 9fc3d12CompareJuly 25, 2025 14:28
prompt: z.string().optional(),
tools: z.record(z.string(), z.boolean()).optional(),
disable: z.boolean().optional(),
path: z.string().optional(),

@mpazikmpazikJul 25, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most questionable part of the PR.

Couldn't find any better solution. Would be greateful for an opinion

@mpazikmpazik mentioned this pull request Jul 25, 2025
@mpazikmpazik changed the title Support prompt references (@file.txt and $ls src) for modes and agentsSupport prompt references (@file.txt and `$ls src`) for modes and agentsJul 25, 2025
@mpazikmpazik changed the title Support prompt references (@file.txt and `$ls src`) for modes and agentsSupport prompt references (@file.txt and $ls src) for modes and agentsJul 25, 2025
@github-actions
github-actionsBotforce-pushed the dev branch 3 times, most recently from f1dc981 to 3e15a39CompareNovember 22, 2025 18:07
@github-actions
github-actionsBotforce-pushed the dev branch 3 times, most recently from f8ee907 to 6a9856dCompareNovember 27, 2025 01:29
@thdxr
thdxrforce-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7CompareJanuary 30, 2026 14:37
@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@mpazik