Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 17, 2026

Summary

Refactored GenerateInstructions() and getToolsetInstructions() in pkg/github/instructions.go to use strings.Builder instead of string slices with append() and strings.Join(), matching the pattern used in the documentation generator.

Why

Improves consistency across the codebase and provides better performance through fewer allocations. The documentation generator already uses this pattern successfully.

What changed

  • GenerateInstructions(): replaced []string + append() + strings.Join() with strings.Builder
  • getToolsetInstructions(): replaced string concatenation with strings.Builder in all switch cases
  • Reordered logic to write base instruction first, then conditional additions
  • Maintained identical output format (all tests pass)

Before:

var instructions []string
instructions = append(instructions, "text")
return strings.Join(allInstructions, " ")

After:

var buf strings.Builder
buf.WriteString("text")
return buf.String()

MCP impact

  • No tool or API changes

Security / limits

  • No security or limits impact

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
Original prompt

Look at using the Golang string builder patter for server instructions (like documentation generator does). I think it's probably a bit less clear if good idea or not considering it's a much more conditional set of content whereas the docs are largely all linear, but I want to see an implementation concretely before I decide if I like it.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Explore Golang string builder pattern for server instructions Refactor server instructions to use strings.Builder pattern Jan 17, 2026
Copilot AI requested a review from SamMorrowDrums January 17, 2026 16:14
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.

2 participants