Agent skill

Implementing Command Palettes

by AgentWorkforce in AgentWorkforce/relay

A skill your agent uses when building Cmd+K command palettes in React - covers keyboard navigation with arrow keys, keeping selected items in view with scrollIntoView, filtering with shortcut…

Apache-2.0Auto-check passedFrontend & Design

Install Implementing Command Palettes

skills CLI
$ npx skills add AgentWorkforce/relay --skill implementing-command-palettes -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install AgentWorkforce/relay implementing-command-palettes --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/AgentWorkforce/relay.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/implementing-command-palettes .claude/skills/implementing-command-palettes && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
implementing-command-palettes
GitHub stars
865
Used in
1 other repo
Token cost
~2.5k tokens
SKILL.md length
408 words
Files
1
Skills in repo
14
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when building Cmd+K command palettes in React - covers keyboard navigation with arrow keys, keeping selected items in view with scrollIntoView, filtering with shortcut…

  • Building Cmd+K command palettes in React - covers keyboard navigation with arrow keys
  • SKILL.md covers Overview, When to Use, Quick Reference and Keyboard Navigation, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Keeping selected items in view with scrollIntoView

What it does

Implementing Command Palettes is an agent skill from AgentWorkforce/relay. 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

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Frontend & Design, covering Accessibility. It works with React. The repository describes itself as: Infrastructure for coding agents. The licence is Apache-2.0.

When your agent uses it

  • Building Cmd+K command palettes in React - covers keyboard navigation with arrow keys
  • Keeping selected items in view with scrollIntoView
  • Filtering with shortcut matching
  • Preventing infinite re-renders from reference instability

Example prompts

  • “/implementing-command-palettes”

What it can do on your machine

Read from SKILL.md and the folder at commit 734600d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Implementing Command Palettes loads about 2.5k tokens when it runs. Until then it costs about 68 tokens; SKILL.md has 408 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~68
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from AgentWorkforce/relay at commit 734600d, republished under its Apache-2.0 licence (© AgentWorkforce). 408 words, ~2,462 tokens.

Download SKILL.mdSave it as .claude/skills/implementing-command-palettes/SKILL.md (or your agent's skills folder).
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

Implementing Command Palettes

Overview

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.

When to Use

  • Building a Cmd+K command palette in React
  • Implementing arrow key navigation with visual selection
  • Keeping selected items visible during keyboard navigation
  • Filtering commands by label text AND keyboard shortcuts
  • Experiencing infinite re-renders when commands update

Quick Reference

FeatureImplementation
Arrow navigationTrack selectedIndex, clamp with Math.min/max
Keep in viewscrollIntoView({ block: 'nearest', behavior: 'smooth' })
Shortcut matchingStrip spaces from shortcuts, match against query
Stable iconsDefine icon elements outside component
Stable handlersuseCallback + noop constant for disabled states

Keyboard Navigation

Index Management
tsx
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;
    }
  };

  window.addEventListener('keydown', handleKeyDown);
  return () => window.removeEventListener('keydown', handleKeyDown);
}, [isOpen, filteredItems, selectedIndex, close]);

Key patterns:

  • e.preventDefault() stops arrow keys from scrolling the page
  • Math.min/max prevents index going out of bounds
  • Effect depends on filteredItems so navigation updates when filter changes
Reset Selection on Query Change
tsx
<input
  value={query}
  onChange={(e) => {
    setQuery(e.target.value);
    setSelectedIndex(0); // Reset to first item when query changes
  }}
/>

Keeping Selected Item in View

Using Refs Array
tsx
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>
  ));
}
Alternative: Single Ref for Selected Item
tsx
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'?

  • 'nearest' only scrolls if the element is outside the visible area
  • 'center' would scroll even when item is already visible, causing jarring movement
  • 'start' or 'end' would always align to top/bottom

Filtering with Shortcut Matching

tsx
const filteredCommands = commands.filter((command) => {
  const q = query.toLowerCase().trim();
  if (!q) return true;

  // Standard label matching
  if (command.label.toLowerCase().includes(q)) return true;

  // Shortcut matching: "gd" matches "g d", "gb" matches "g b"
  if (command.shortcut) {
    const shortcutNoSpaces = command.shortcut.toLowerCase().replace(/\s+/g, '');
    if (shortcutNoSpaces.startsWith(q) || shortcutNoSpaces.includes(q)) {
      return true;
    }
  }

  // For numbered items (PRs, issues), match by number
  if (command.type === 'pr') {
    const numberMatch = q.match(/^#?(\d+)$/);
    if (numberMatch) {
      return String(command.pr.number).startsWith(numberMatch[1]);
    }
  }

  return false;
});

Why strip spaces from shortcuts? Users type continuously without spaces. Shortcut "g d" should match when user types "gd".

Preventing Re-Render Loops

Command palettes often suffer from infinite re-renders when command objects are recreated every render.

Problem: Unstable References
tsx
// BAD: Icons recreated every render
function usePageCommands() {
  const commands = useMemo(
    () => [
      {
        label: 'Sync',
        icon: <RefreshCw size={16} />, // New element every render!
        action: () => onSync(), // New function every render!
      },
    ],
    [onSync]
  ); // Even with deps, icon is new

  useRegisterCommands(commands); // Triggers re-registration → re-render loop
}
Solution: Stable References
tsx
// GOOD: Icons defined OUTSIDE component
const refreshIcon = <RefreshCw size={16} />;
const refreshSpinIcon = <RefreshCw size={16} className="animate-spin" />;
const noop = () => {};

function usePageCommands({ onSync, isSyncing }: Props) {
  // Memoize handlers
  const handleSync = useCallback(() => onSync?.(), [onSync]);

  const commands = useMemo(
    () => [
      {
        label: isSyncing ? 'Syncing...' : 'Sync',
        icon: isSyncing ? refreshSpinIcon : refreshIcon, // Stable references
        action: isSyncing ? noop : handleSync, // noop, not undefined
      },
    ],
    [isSyncing, handleSync]
  );

  useRegisterCommands(commands);
}
Show full SKILL.md (164 more words)Show less
Label-Based Change Detection

Instead of comparing object references, compare by labels:

tsx
export function useRegisterCommands(commands: CommandItem[]) {
  const { registerCommands, unregisterCommands } = useCommandPalette();

  // Create stable ID based on LABELS, not object references
  const commandIds = useMemo(
    () =>
      commands
        .map((c) => {
          if (c.type === 'nav') return `nav:${c.path}`;
          return `action:${c.label}`;
        })
        .sort()
        .join('|'),
    [commands]
  );

  const commandsRef = useRef<CommandItem[]>(commands);
  useEffect(() => {
    commandsRef.current = commands;
  });

  const prevIdsRef = useRef<string>('');

  useEffect(() => {
    // Only register if structure actually changed
    if (commandIds !== prevIdsRef.current) {
      registerCommands(commandsRef.current);
      prevIdsRef.current = commandIds;
      return () => unregisterCommands(commandsRef.current);
    }
  }, [commandIds, registerCommands, unregisterCommands]);
}

Command Type Patterns

tsx
type CommandItem =
  | { type: 'action'; label: string; icon?: React.ReactNode; action: () => void; shortcut?: string }
  | { type: 'nav'; label: string; icon?: React.ReactNode; path: string; shortcut?: string }
  | { type: 'file'; file: FileType; label: string; icon?: React.ReactNode }
  | { type: 'pr'; pr: PRType; label: string; icon?: React.ReactNode };

// Execute based on type
function executeCommand(command: CommandItem) {
  switch (command.type) {
    case 'action':
      command.action();
      break;
    case 'nav':
      navigate(command.path);
      break;
    case 'file':
      onFileSelect(command.file);
      break;
    case 'pr':
      navigate(`/repos/${command.owner}/${command.repo}/pulls/${command.pr.number}`);
      break;
  }
}

Common Mistakes

MistakeWhy It FailsFix
Icons inside useMemoNew icon element every renderDefine icons as constants outside component
Not resetting index on filterArrow keys start from wrong positionsetSelectedIndex(0) in onChange
block: 'center' in scrollIntoViewJarring scroll when item already visibleUse block: 'nearest'
Missing e.preventDefault()Arrow keys scroll page AND move selectionAdd preventDefault for ArrowUp/Down
Forgetting cleanup in useEffectEvent listeners accumulateReturn cleanup function
undefined for disabled actionType error or click does nothingUse noop constant

Testing Checklist

  • Cmd+K opens palette, Escape closes
  • Arrow Down moves to next item (stops at last)
  • Arrow Up moves to previous item (stops at first)
  • Enter executes selected command and closes palette
  • Selected item scrolls into view when navigating long lists
  • Typing resets selection to first matching item
  • Shortcuts like "gd" match commands with shortcut "g d"
  • No console errors about re-renders or maximum update depth

© AgentWorkforce, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/implementing-command-palettes of AgentWorkforce/relay.

Open the folder on GitHubat commit 734600d

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in AgentWorkforce/relay, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Implementing Command Palettes next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Implementing Command Palettes compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Implementing Command Palettes this skillAgentWorkforce/relay8651 repos~2.5kAutomated safety check: PassApache-2.0
Wcag Audit PatternsvmDeshpande/ai-agent-automation17810 repos~610Automated safety check: PassApache-2.0
UI/UX Design System AdvisorGalaxy-Dawn/claude-scholar5.7k1 repos~1.1kAutomated safety check: PassMIT
Extract DesignManavarya09/design-extract4.2k—~786Automated safety check: NotesMIT
Accessibility CompliancevmDeshpande/ai-agent-automation1783 repos~601Automated safety check: PassApache-2.0
React Ariaintentui/laravel1621 repos~3.9kAutomated safety check: PassApache-2.0

Similar skills

  • Wcag Audit Patterns

    vmDeshpande/ai-agent-automation

    Conduct WCAG 2.2 accessibility audits with automated testing, manual verification, and remediation guidance.

    178 GitHub starsUsed in 10 repos~610 tokens
    Frontend & DesignAuto-check passed
  • UI/UX Design System Advisor

    Galaxy-Dawn/claude-scholar

    Turns a vague UI request into a concrete design system with style, palette, typography and layout guidance from a search script, plus stack-specific implementation advice.

    5.7k GitHub starsUsed in 1 repo~1.1k tokens
    Frontend & DesignAuto-check passed
  • Extract Design

    Manavarya09/design-extract

    Extract the full design language from any website URL. An agent skill from Manavarya09/design-extract.

    4.2k GitHub stars~786 tokensUpdated 8 days ago
    Frontend & DesignAuto-check: notes
  • Accessibility Compliance

    vmDeshpande/ai-agent-automation

    Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support.

    178 GitHub starsUsed in 3 repos~601 tokens
    Frontend & DesignAuto-check passed
  • React Aria

    intentui/laravel

    Build accessible UI components with React Aria Components. An agent skill from intentui/laravel.

    162 GitHub starsUsed in 1 repo~3.9k tokens
    Frontend & DesignAuto-check passed
  • Instui Docs

    instructure/instructure-ui

    Look up authoritative Instructure UI (InstUI, @instructure/ui-) documentation — component APIs, props, theme variables, usage examples, and guides — by querying instructure.design's plaintext docs.

    482 GitHub stars~498 tokensUpdated today
    Frontend & DesignAuto-check passed

More from AgentWorkforce/relay

All 14 skills in this repo
  • A skill your agent uses when testing web applications with visual verification - automates Chrome browser interactions, element selection, and screenshot capture for confirming UI functionality

    865 GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed
  • Agent Relay

    AgentWorkforce/relay

    A skill your agent uses when you need Codex to coordinate multiple agents through Agent Relay for peer-to-peer messaging, lead/worker handoffs, or shared status tracking across sub-agents and…

    865 GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • Debugging Websocket Issues

    AgentWorkforce/relay

    A skill your agent uses when seeing WebSocket errors like "Invalid frame header", "RSV1 must be clear", or "WSERRUNEXPECTEDRSV1" - covers multiple WebSocketServer conflicts, compression issues, and…

    865 GitHub starsUsed in 1 repo~1.3k tokens
    Auto-check passed
  • GitHub OAuth Nango Integration

    AgentWorkforce/relay

    A skill your agent uses when implementing GitHub OAuth + GitHub App authentication with Nango - provides two-connection pattern for user login and repo access with webhook handling

    865 GitHub starsUsed in 1 repo~3.4k tokens
    Auto-check passed
  • Using Agent Relay

    AgentWorkforce/relay

    A skill your agent uses when you are a registered relay agent (a spawned worker, or a lead that called registeragent) coordinating with peers in real time over current Agent Relay MCP tools -…

    865 GitHub starsUsed in 1 repo~2k tokens
    Auto-check passed
  • A skill your agent uses when deploying changes to staging across relay, relay-dashboard, and relay-cloud repos - coordinates multi-repo branch syncing using git worktrees, automatically triggers…

    865 GitHub stars~3.2k tokensUpdated today
    Auto-check passed

Works with

Questions about Implementing Command Palettes

What does Implementing Command Palettes do?

A skill your agent uses when building Cmd+K command palettes in React - covers keyboard navigation with arrow keys, keeping selected items in view with scrollIntoView, filtering with shortcut…. Implementing Command Palettes is an agent skill from AgentWorkforce/relay.

When should I use Implementing Command Palettes?

Implementing Command Palettes fits situations like: building Cmd+K command palettes in React - covers keyboard navigation with arrow keys; keeping selected items in view with scrollIntoView; filtering with shortcut matching; preventing infinite re-renders from reference instability.

How do I install Implementing Command Palettes in Claude Code?

Run `npx skills add AgentWorkforce/relay --skill implementing-command-palettes -a claude-code`. Or copy the skill folder (.claude/skills/implementing-command-palettes in AgentWorkforce/relay) into .claude/skills/implementing-command-palettes in your project. Claude Code loads it when a task matches its description.

How do I install Implementing Command Palettes in Codex?

Run `npx skills add AgentWorkforce/relay --skill implementing-command-palettes -a codex`. Or copy the skill folder (.claude/skills/implementing-command-palettes in AgentWorkforce/relay) into .agents/skills/implementing-command-palettes in your project. Codex loads it when a task matches its description.

Can I use Implementing Command Palettes in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add AgentWorkforce/relay --skill implementing-command-palettes -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/implementing-command-palettes, .gemini/skills/implementing-command-palettes, .github/skills/implementing-command-palettes and .opencode/skills/implementing-command-palettes in your project.

What does Implementing Command Palettes need to run?

SKILL.md names no scripts, command-line tools or credentials: Implementing Command Palettes is instructions for the agent only.

Does Implementing Command Palettes access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Implementing Command Palettes safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Implementing Command Palettes use?

Implementing Command Palettes is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Implementing Command Palettes use?

About 2.5k tokens (SKILL.md is roughly 9.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Implementing Command Palettes?

Skills that share tags, products or a category with Implementing Command Palettes: Wcag Audit Patterns (vmDeshpande/ai-agent-automation, 178 stars), UI/UX Design System Advisor (Galaxy-Dawn/claude-scholar, 5.7k stars), Extract Design (Manavarya09/design-extract, 4.2k stars) and Accessibility Compliance (vmDeshpande/ai-agent-automation, 178 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Implementing Command Palettes?

AgentWorkforce (a GitHub organization) maintains it in AgentWorkforce/relay, which has 865 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on October 7, 2026.

Source: AgentWorkforce/relay on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.