Skip to content

feat: Auto-added shell context via go-template string#110

Merged
baalimago merged 7 commits intomainfrom
feat/auto-append-shell-context
Mar 8, 2026
Merged

feat: Auto-added shell context via go-template string#110
baalimago merged 7 commits intomainfrom
feat/auto-append-shell-context

Conversation

@baalimago
Copy link
Copy Markdown
Owner

@baalimago baalimago commented Mar 8, 2026

This one is cool! I always try to be as token-efficient as possible. I think that inference cost will be significantly more expensive post-ai-bubble.
If not, being able to solve a problem in the least amount of tokens possible is an indicator on how concentrated the task has been. This philosophy is what keeps me focusing on clai in addition to codex and claude, which I do use on the regular as well.
It's an exercise in learning how to best utilize LLMs to achieve some goal.

With this in mind! I found myself repeatedly prompting LLMs to use pwd and date tools, and to fetch certain files to
setup context. Then it struck me that I can simply add this to the initial query instead. This lead to appending certain
fixed data. But then I thought I might as well expand on this with templates: which I did.

So this PR introduces fully configurable context fetches, with arguments.

Example suggestions (in addition to the current default):

  • Auto-inject AGENTS.md into the prompt instead of relying on LLM to fetch it
  • Pre-add skils: find /path/toskills -maxdepth 1 -type f -exec cat {} +
  • Utilize as a pre-hook that logs every time you make some clai query

As we're using go templates + shell commands, it's very powerful. The timeout is configurable as well, so it could be a long
running thing (if needed).


Features:

  • Set flag -add-shell-context=<shellContextTemplate>/-asc=<shellContextTemplate> to auto-attach some shell context
  • Introduced shell context:
    • Configured files are found in <claiConfigDir>/shellContexts
    • It's a golang template string:
      • This means conditional context fields
      • Add variables within the same shellContext conf file
      • Infinite variablity!
    • Configure using clai setup -> 4
    • Auto-add shell context to some profile by setting the new shell_context field
    • There's a new default shell context named default
  • Refactored clai setup to use the generic table tool to homogenize look and feel

To try it out:

clai -asc=default query What do you know about my current context\?

@baalimago baalimago merged commit fba65fe into main Mar 8, 2026
2 checks passed
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