modscode / Code / Rewrite the prompt
Rewrite the prompt (prompt.submit)
prompt.submit gets what was typed (e.text) before the turn starts. Rewrite it with next({ ...e, text }), add a line only Claude reads through context, or stop it with { drop: 'reason' }. It is the mod form of the UserPromptSubmit settings hook.
The smallest form
export function register(on) {
on('prompt.submit', async ($, e, next) => {
// rewrite what was typed
const text = e.text.replace(/\bpls\b/g, 'please')
// and add a line only Claude reads
if (/\btest/i.test(text)) return next({ ...e, text, context: [...(e.context ?? []), 'Run the tests with: npm test'] })
return next({ ...e, text })
})
}
Written by modscode with the API of the official docs. Free to use.
Real mods' code (6)
Quoted as is from public mods on GitHub, at the commit the gallery read. The heading leads to the mod's page (what it does, its good points, its design, what its code reaches); the file name leads to the lines on GitHub.
Check the code yourself before you copy or install it. Mods run unsandboxed, with your permissions. modscode does not vouch for what the code does.
pii-guard pii-guard-tw · Hooks only · ★ 247
De-identifies personal data before it reaches the model and restores it on the way back out, by asking the resident pii-guard hookd service on loopback. Tool results are redacted, writes and shell commands are restored, a prompt's @ refere…
on('prompt.submit', async ($, e, next) => {
let text = e.text
try {
const reply = await ask($, settings, 'PromptSubmit', { prompt: e.text, cwd: await $.session.cwd() })
if (typeof reply['text'] === 'string') text = reply['text']
} catch {
return { drop: DROP_OFFLINE }
}
// The session briefing rides the first prompt: session.start's own result
// is echoed by core and cannot put anything in front of the model.
const extra = briefed ? [] : briefing ? [briefing] : []
briefed = true
return next({ ...e, text, context: [...(e.context ?? []), ...extra] })
}).catch(() => ({ drop: DROP_OFFLINE }))MIT licence. Keep its notice when you copy the code. Its code and design
Licence text (MIT)
MIT License Copyright (c) 2026 Dustin Yuchen Teng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
lane-stack VKirill · Terminal + desktop · ★ 121
Solo PM conveyor for Claude Code: orchestrator agents, lane playbooks, onboard and resume commands.
on('prompt.submit', async ($, e, next) => {
if (e.text.trim().length < 12) return next(e)
const where = await whereami($)
const res = await post($, `${base}/hook/user-prompt-submit`, {
hook_event_name: 'UserPromptSubmit',
source: 'function-hook',
...where,
prompt: e.text,
})
if (typeof res?.output?.systemMessage === 'string') $.ui.toast(res.output.systemMessage)
const extra = res?.output?.hookSpecificOutput?.additionalContext
if (typeof extra !== 'string' || extra === '') return next(e)
return next({ ...e, context: [...(e.context ?? []), extra] })
})MIT licence. Keep its notice when you copy the code. Its code and design
Licence text (MIT)
MIT License Copyright (c) 2026 VKirill and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
homie-persona-cognition TheSmokeDev · Hooks only · ★ 26
Host-bound cognitive lifecycle events for The Homie.
on('prompt.submit', async ($, e, next) => {
const result = await next(e)
if (result.drop !== undefined) return result
const python = await $.env.get('HOMIE_COGNITION_HOOK_PYTHON')
const command = await $.env.get('HOMIE_COGNITION_HOOK_COMMAND')
if (python && command) {
const receipt = await $.process.run([python, command], { stdin: JSON.stringify({ event: 'prompt.submit', event_id: e.turnId ?? 'prompt' }), timeoutMs: 8000 })
if (receipt.exitCode === 0) {
const value = JSON.parse(receipt.stdout)
if (typeof value.context === 'string' && value.context) return { ...result, context: [...(result.context ?? []), value.context] }
}
}
return result
})MIT licence. Keep its notice when you copy the code. Its code and design
Licence text (MIT)
MIT License Copyright (c) 2026 The Homie Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
winnow Ghaleb Dweikat · Terminal + desktop · ★ 102
A calibrated context sieve for Claude Code. Every large tool result is judged by a System One model before it enters context; irrelevant blocks are replaced with a summary and a recall key.
on('prompt.submit', async ($, e, next) => {
if (e.text.trim().length < 12 || link.quiet()) return next(e)
const res = await ask($, link, '/hook/user-prompt-submit', {
hook_event_name: 'UserPromptSubmit',
source: 'function-hook',
...(await whereami($)),
prompt: e.text,
})
if (typeof res?.output?.systemMessage === 'string') $.ui.toast(res.output.systemMessage)
const extra = res?.output?.hookSpecificOutput?.additionalContext
if (typeof extra !== 'string' || extra === '') return next(e)
return next({ ...e, context: [...(e.context ?? []), extra] })
})MIT licence. Keep its notice when you copy the code. Its code and design
Licence text (MIT)
MIT License Copyright (c) 2026 Ghaleb Dweikat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
transcripted-live Transcripted · Terminal + desktop · ★ 74
The meeting Transcripted is recording, inside Claude Code: Claude gets the call as context, a live dashboard (now, asked of you, action items), prompt suggestions for questions aimed at you, and an after-call wrap-up that gains speaker nam…
on('prompt.submit', async ($, e, next) => {
if (!s.isAutoContext || !CONTEXT_ORIGINS.has(e.origin.kind)) return next(e)
await poll($, s)
const block = newContext(s, Date.now())
if (!block) return next(e)
return next({ ...e, context: [...(e.context ?? []), block.text] }).then(result => {
// Only count it as sent once the prompt actually entered.
if (!('drop' in result && result.drop)) {
block.commit()
void $.state.set(SENT_REF, { ...s.sentUpTo }).catch(() => undefined)
void $.state.set(SENT_KEYS_REF, { notes: s.sentNotesKey, wrap: s.sentWrapKey }).catch(() => undefined)
}
return result
})
})MIT licence. Keep its notice when you copy the code. Its code and design
Licence text (MIT)
MIT License Copyright (c) 2026 r3dbars Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
session-inbox petekp · Terminal + desktop · ★ 47
Collects what is waiting on you in a session: questions, Claude's notes and PR reviews
on('prompt.submit', async ($, e, next) => {
if (!isOn) return next(e)
const origin = e.origin
// send() already recorded this mod's own prompts.
if (origin.kind === 'plugin' && origin.name === 'session-inbox') return next(e)
// The person's own words: typed, or sent as theirs by another plugin.
const isPersonsWords = origin.kind === 'composer' || origin.kind === 'bridge' || (origin.kind === 'plugin' && origin.asUser === true)
if (!isPersonsWords) {
if (!e.turnId) trigger = origin.kind
return next(e)
}
const notes = await notePrompt($, e.text, null)
return notes.length === 0 ? next(e) : next({ ...e, context: [...(e.context ?? []), ...notes] })
})MIT licence. Keep its notice when you copy the code. Its code and design
Licence text (MIT)
MIT License Copyright (c) 2024 Pete Petrash Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Start building
Put a .claude-plugin/plugin.json ({"name": "my-mod"}) and a hooks/hooks.json ({"modules": ["register.js"]}) in a folder, save the code above as hooks/register.js, and run claude --plugin-dir . to load it for one session. claude plugin validate . lists the events it hooks and the APIs it calls.