MCPcopy Create free account
hub / github.com/codeaashu/claude-code / buildMessages

Function buildMessages

src/utils/hooks/skillImprovement.ts:94–127  ·  view source on GitHub ↗
(context)

Source from the content-addressed store, hash-verified

92 },
93
94 buildMessages(context) {
95 const projectSkill = findProjectSkill()!
96 // Only analyze messages since the last check — the skill definition
97 // provides enough context for the classifier to understand corrections
98 const newMessages = context.messages.slice(lastAnalyzedIndex)
99 lastAnalyzedIndex = context.messages.length
100
101 return [
102 createUserMessage({
103 content: `You are analyzing a conversation where a user is executing a skill (a repeatable process).
104Your job: identify if the user's recent messages contain preferences, requests, or corrections that should be permanently added to the skill definition for future runs.
105
106<skill_definition>
107${projectSkill.content}
108</skill_definition>
109
110<recent_messages>
111${formatRecentMessages(newMessages)}
112</recent_messages>
113
114Look for:
115- Requests to add, change, or remove steps: "can you also ask me X", "please do Y too", "don't do Z"
116- Preferences about how steps should work: "ask me about energy levels", "note the time", "use a casual tone"
117- Corrections: "no, do X instead", "always use Y", "make sure to..."
118
119Ignore:
120- Routine conversation that doesn't generalize (one-time answers, chitchat)
121- Things the skill already does
122
123Output a JSON array inside <updates> tags. Each item: {"section": "which step/section to modify or 'new step'", "change": "what to add/modify", "reason": "which user message prompted this"}.
124Output <updates>[]</updates> if no updates are needed.`,
125 }),
126 ]
127 },
128
129 systemPrompt:
130 'You detect user preferences and process improvements during skill execution. Flag anything the user asks for that should be remembered for next time.',

Callers

nothing calls this directly

Calls 3

findProjectSkillFunction · 0.85
createUserMessageFunction · 0.85
formatRecentMessagesFunction · 0.85

Tested by

no test coverage detected