Skip to content

Conversation

@matleh
Copy link
Contributor

@matleh matleh commented Jan 30, 2026

Relates to #65

Summary

  • Add templates.prime config option to .beans.yml for overriding the built-in prime document with a custom Go template file
  • Custom templates have access to all built-in template variables plus {{.OriginalPrime}} (the fully-rendered built-in prime output)
  • Graceful fallback: when a configured template file is missing or has parse errors, beans prime warns on stderr and outputs the built-in prime instead of failing
  • beans check validates that the custom prime template file exists when configured

This allows users to add project-specific or agent-specific instructions (like those suggested in #65) without forking the built-in prime template. Users can wrap the original prime with their own additions via {{.OriginalPrime}}, or replace it entirely.

Configuration

beans:
    path: .beans
    prefix: beans-

templates:
    prime: extras/custom-prime.tmpl  # path relative to .beans.yml

Template Variables

Custom templates have access to:

  • {{.GraphQLSchema}} - The GraphQL schema
  • {{.Types}} - Type configs (name, color, description)
  • {{.Statuses}} - Status configs
  • {{.Priorities}} - Priority configs
  • {{.OriginalPrime}} - The fully-rendered built-in prime output

Example

# Project-Specific Instructions

Custom guidance for this project...

{{.OriginalPrime}}

## Additional Context

More project-specific notes...

Changes

  • internal/config/config.go: Add TemplatesConfig struct, Templates field on Config, ResolvePrimeTemplatePath() method
  • cmd/prime.go: Extract renderPrime() function, load config, handle custom template with fallback
  • cmd/check.go: Validate custom prime template file exists
  • cmd/prime_test.go: New test file covering rendering, fallback, all template variables
  • internal/config/config_test.go: Tests for path resolution, config loading, save/load round-trip

Design Notes

The templates section is a new top-level config key (separate from beans) to allow future extensibility:

# Future: agent-specific prime templates
templates:
    prime:
        default: extras/custom-prime.tmpl
        claude: extras/claude-specific.tmpl
        opencode: extras/opencode-specific.tmpl

- Add templates.prime config option to .beans.yml for overriding
  the built-in prime document with a custom Go template file
- Add TemplatesConfig struct with Prime field, resolved relative
  to the config file directory (same as beans.path)
- Custom templates have access to all built-in variables plus
  {{.OriginalPrime}} which contains the fully-rendered built-in
  prime output
- When custom template file is missing or has parse errors, fall
  back to built-in prime with a warning on stderr
- Add prime template existence check to beans check command
- Extract renderPrime() for testability; add comprehensive tests
  for rendering, fallback behavior, and config round-trips
@matleh
Copy link
Contributor Author

matleh commented Jan 30, 2026

Follow-up consideration: user-global config

We discussed adding support for a user-global config (e.g., ~/.config/beans/config.yml or $XDG_CONFIG_HOME/beans/config.yml) as a future enhancement. This would allow users to set a default custom prime template that applies across all their projects without repeating the config in every .beans.yml.

Rough shape:

  • Look for a global config at a well-known path (respecting $XDG_CONFIG_HOME)
  • Project .beans.yml overrides the global config (project wins)
  • A global templates.prime would apply to all projects unless the project specifies its own
  • Merge semantics TBD (simple override per-key? deep merge?)

This is out of scope for this PR but the templates section design accommodates it — a global config could provide default templates while projects override specific ones.

@matleh matleh marked this pull request as ready for review January 30, 2026 13:37
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