Skip to content

Conversation

mpazik
Copy link

@mpazik mpazik commented Jul 25, 2025

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 mpazik force-pushed the support-references-in-prompts branch from b89691d to 9fc3d12 Compare July 25, 2025 14:28
@@ -102,6 +103,7 @@ export namespace Config {
prompt: z.string().optional(),
tools: z.record(z.string(), z.boolean()).optional(),
disable: z.boolean().optional(),
path: z.string().optional(),
Copy link
Author

@mpazik mpazik Jul 25, 2025

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

@mpazik mpazik mentioned this pull request Jul 25, 2025
@mpazik mpazik changed the title Support prompt references (@file.txt and $ls src) for modes and agents Support prompt references (@file.txt and `$ls src `) for modes and agents Jul 25, 2025
@mpazik mpazik changed the title Support prompt references (@file.txt and `$ls src `) for modes and agents Support prompt references (@file.txt and $ls src) for modes and agents Jul 25, 2025
Sign up for free to 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