browser-testing-with-s…
Use when testing web applications with visual verification - automates Chrome browser interactions, element selection, and screenshot capture for confirming UI…
Use when building Cmd+K command palettes in React - covers keyboard navigation with arrow keys, keeping selected items in view with scrollIntoView, filtering with shortcut matching, and preventing infinite re-renders from reference instability
$ npx -y skills add AgentWorkforce/relay --skill implementing-command-palettes --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/implementing-command-palettesContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when building Cmd+K command palettes in React - covers keyboard navigation with arrow keys, keeping selected items in view with scrollIntoView, filtering with shortcut matching, and preventing infinite re-renders from reference instability
name: implementing-command-palettes description: Use when building Cmd+K command palettes in React - covers keyboard navigation with arrow keys, keeping selected items in view with scrollIntoView, filtering with shortcut matching, and preventing infinite re-renders from reference instability
Command palettes (Cmd+K / Ctrl+K) need precise keyboard navigation, scroll behavior, and stable references to avoid re-render loops. This skill covers the mechanical patterns that make command palettes feel responsive.
| Feature | Implementation | | ----------------- | ---------------------------------------------------------- | | Arrow navigation | Track `selectedIndex`, clamp with `Math.min/max` | | Keep in view | `scrollIntoView({ block: 'nearest', behavior: 'smooth' })` | | Shortcut matching | Strip spaces from shortcuts, match against query | | Stable icons | Define icon elements outside component | | Stable handlers | `useCallback` + `noop` constant for disabled states |
**This is the most common source of bugs.** The keyboard effect must ONLY run when the palette is open. Use a wrapper component:
// Wrapper ensures effects only run when open
export function CommandPalette(props: CommandPaletteProps) {
if (!props.isOpen) return null;
return <CommandPaletteContent {...props} />;
}
// Content component - effects run on mount/unmount
function CommandPaletteContent({ onClose, ... }: CommandPaletteProps) {
// Effects here only run when palette is visible
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => { ... };
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [deps]);
return <div>...</div>;
}**Why this matters:**
The input MUST be focused (for typing to work), and keyboard navigation MUST use `window.addEventListener`. This works because:
// Input with autoFocus - NOT setTimeout focus
<input
autoFocus
type="text"
value={query}
onChange={(e) => {
setQuery(e.target.value);
setSelectedIndex(0); // Reset to first item when query changes
}}
/>const [selectedIndex, setSelectedIndex] = useState(0);
useEffect(() => {
if (!isOpen) return;
const handleKeyDown = (e: KeyboardEvent) => {
switch (e.key) {
case 'ArrowDown':
e.preventDefault();
// Clamp to last item
setSelectedIndex((prev) => Math.min(prev + 1, filteredItems.length - 1));
break;
case 'ArrowUp':
e.preventDefault();
// Clamp to first item
setSelectedIndex((prev) => Math.max(prev - 1, 0));
break;
case 'Enter':
e.preventDefault();
if (filteredItems[selectedIndex]) {
executeCommand(filteredItems[selectedIndex]);
close();
}
break;
case 'Escape':
e.preventDefault();
close();
break;
}
};
// NO capture phase needed - simple window listener works with focused input
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [isOpen, filteredItems, selectedIndex, close]);**Key patterns:**
const itemRefs = useRef<(HTMLButtonElement | null)[]>([]);
// Scroll effect - runs when selection changes
useEffect(() => {
const selectedItem = itemRefs.current[selectedIndex];
if (selectedItem) {
selectedItem.scrollIntoView({
block: 'nearest', // Minimal scroll - only scroll if needed
behavior: 'smooth', // Smooth animation
});
}
}, [selectedIndex]);
// Assign refs in render
{
filteredItems.map((item, index) => (
<button
key={index}
ref={(el) => {
itemRefs.current[index] = el;
}}
className={index === selectedIndex ? 'bg-blue-100' : ''}
>
{item.label}
</button>
));
}const selectedItemRef = useRef<HTMLButtonElement>(null);
useEffect(() => {
if (isOpen && selectedItemRef.current) {
selectedItemRef.current.scrollIntoView({
block: 'nearest',
behavior: 'smooth',
});
}
}, [isOpen, selectedIndex]);
// Only assign ref to selected item
<button
ref={index === selectedIndex ? selectedItemRef : null}
>**Why `block: 'nearest'`?**
const fil
Let Claude Code message Codex. Let your Hyperagent talk to your Hermes agent. Give your custom agents a way to message each other.
Repo: AgentWorkforce/relay
Use when testing web applications with visual verification - automates Chrome browser interactions, element selection, and screenshot capture for confirming UI…
Use when coordinating multiple AI agents with Agent Relay's workflow engine and need to pick the right orchestration pattern - covers the 10 core patterns…
Use when creating or improving Claude Code agents. Expert guidance on agent file structure, frontmatter, persona definition, tool access, model selection, and…
Use when creating or publishing Claude Code hooks - covers executable format, event types, JSON I/O, exit codes, security requirements, and PRPM package…
Use when creating or fixing .claude/rules/ files - provides correct paths frontmatter (not globs), glob patterns, and avoids Cursor-specific fields like…
Use when creating new Claude Code skills or improving existing ones - ensures skills are discoverable, scannable, and effective through proper structure, CSO…