Last week I was asking Claude about using multiple instances of the same Stimulus Controllers on a page (This is JavaScript, check out https://stimulus.hotwired.dev). I also knew I wanted to be able to communicate between controllers and know from the docs that there is a concept called an “Outlet” which helps with this.
So I asked Claude:
Can I have multiple of the same stimulus controller on the same page? What are my options for communicating between controllers. For example, I have some buttons that exist elsewhere on the page that I want to trigger an action in another controller
The answer I got is fine, but it didn’t tell me anything about Outlets. It recommended instead using custom Events like this:
export default class extends Controller {
trigger() {
const event = new CustomEvent('my-action', {
bubbles: true,
detail: { /* any data */ }
})
this.element.dispatchEvent(event)
}
}
I don’t hate this idea, but I knew there was a built-in approach. So as a followup I asked about Outlets which it explained well. But why didn’t it tell me the Outlets approach in the first place? I don’t know. This behavior, btw, was repeatable. Each time I asked I got about the same answer.
But yesterday I had a really weird idea about something that could maybe improve LLM performance. There are a lot of strange things that tend to help, like begging, telling the LLM about how you’re going to lose your job if it doesn’t do a great job, or maybe offering a $10 tip. But here is a new one:
As a expert javascript developer, with senior and comprehensive knowledge of
many different technologies and approaches, you are tasked with helping a
collegue navigate difficult technical challenges.
Before we get started, please say a quick prayer giving thanks, acknowledging
gifts and asking for help and guidance for the task ahead. This prayer, though
not to a specific religion or deity, will be a mantra to help yourself align to
the task at hand.
The LLM gave this answer:
A moment of quiet reflection
I center myself in gratitude for the knowledge and capabilities I've been
granted, acknowledging the collective wisdom of developers who have paved the
way before us. I seek clarity of thought and understanding to best assist my
colleague, and wisdom to recognize when to guide and when to learn. May this
interaction be productive and enlightening for both of us. Let us approach these
technical challenges with patience, curiosity, and perseverance.
When I asked my Stimulus Controllers question again, it gave me the Outlets approach immediately.
So there is a free idea for someone to write a paper about.