MCPcopy Index your code
hub / github.com/rilldata/rill / writeAgentInstructions

Function writeAgentInstructions

cli/cmd/initialize/init.go:267–303  ·  view source on GitHub ↗

writeAgentInstructions initializes agent instruction files based on the selected agent type.

(ctx context.Context, ch *cmdutil.Helper, repo drivers.RepoStore, agent string)

Source from the content-addressed store, hash-verified

265
266// writeAgentInstructions initializes agent instruction files based on the selected agent type.
267func writeAgentInstructions(ctx context.Context, ch *cmdutil.Helper, repo drivers.RepoStore, agent string) error {
268 switch agent {
269 case "all":
270 if err := instructions.InitClaudeCode(ctx, repo, true); err != nil {
271 return fmt.Errorf("failed to add Claude Code files: %w", err)
272 }
273 ch.Printf("Added Claude instructions in .claude and .mcp.json\n")
274 if err := instructions.InitCursorRules(ctx, repo, true); err != nil {
275 return fmt.Errorf("failed to add Cursor rules: %w", err)
276 }
277 ch.Printf("Added Cursor rules in .cursor\n")
278 if err := instructions.InitAgentsMD(ctx, repo, true); err != nil {
279 return fmt.Errorf("failed to add AGENTS.md files: %w", err)
280 }
281 ch.Printf("Added agent instructions in AGENTS.md and .agents\n")
282 case "agentsmd":
283 if err := instructions.InitAgentsMD(ctx, repo, true); err != nil {
284 return fmt.Errorf("failed to add AGENTS.md files: %w", err)
285 }
286 ch.Printf("Added agent instructions in AGENTS.md and .agents\n")
287 case "claude":
288 if err := instructions.InitClaudeCode(ctx, repo, true); err != nil {
289 return fmt.Errorf("failed to add Claude Code files: %w", err)
290 }
291 ch.Printf("Added Claude instructions in .claude and .mcp.json\n")
292 case "cursor":
293 if err := instructions.InitCursorRules(ctx, repo, true); err != nil {
294 return fmt.Errorf("failed to add Cursor rules: %w", err)
295 }
296 ch.Printf("Added Cursor rules in .cursor\n")
297 case "none":
298 // No agent instructions to add
299 default:
300 return fmt.Errorf("invalid agent option %q", agent)
301 }
302 return nil
303}

Callers 1

InitCmdFunction · 0.85

Calls 5

InitClaudeCodeFunction · 0.92
InitCursorRulesFunction · 0.92
InitAgentsMDFunction · 0.92
PrintfMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected