HyperCapslock Agent Skill
HyperCapslock is a native macOS menu-bar app that remaps physical CapsLock → F18 via hidutil and intercepts F18 chords and modifier double-taps via a CGEventTap. All mappings and preferences live in human-readable YAML files and can be validated, backed up, applied, hot-reloaded, and rolled back without restarting the app via the built-in zero-UI CLI.
Reference Documentation
Load these companion references (relative to this SKILL.md) whenever authoring or reviewing YAML configs:
./references/schema-and-actions.md— Complete YAML schemas foraction_mappings.ymlandapp_config.yml, all 15 permanentbuiltin.*action IDs, all 4Triggerkinds, all 8ActionConfigkinds, conditional per-appbindings[],key_remaps, CJKV IME fix strategies, and real-world YAML recipes../references/keycodes.md— Exhaustive lookup table of every valid numeric JavaScriptKeyboardEvent.keyCode(UInt16), reservedF18(129), all 9ModifierKeystrings, andkey_remapssource/destinationenums.
Capability Summary (Answering User Q&A)
When the user asks "What can HyperCapslock do?" or "Can I set up X shortcut?", use this capability matrix:
Supported Triggers (4 kinds)
CapsLock + Key&CapsLock + Shift + Key(hyper_plus_key): HoldCapsLock(optionally withShift) and press any of the 79 supported keys (A–Z,0–9, punctuation, arrows,Space/Enter/Tab/Esc/Backspace/Fwd Del,PgUp/PgDn/Home/End,F1–F17,F19).- Automatic Shift-selection fallback: If
Caps + Shift + <Key>is not explicitly mapped andCaps + <Key>resolves to adirectional,jump, orbackspaceaction, holdingShiftautomatically selects text (e.g.,Caps + Hmoves left←, soCaps + Shift + Hselects left⇧←with zero extra config).
- Automatic Shift-selection fallback: If
Single-Tap CapsLock(single_tap_hyper): Tap and releaseCapsLock(≤ 200ms) without pressing another key. When unmapped, a short tap toggles hardware Caps Lock as usual; map it toEsc, an English input source, orbuiltin.noop(to prevent accidental Caps Lock).Double-Tap CapsLock(double_tap_hyper): TapCapsLocktwice withindouble_tap_window_ms(100–500ms, default200ms).Double-Tap Modifier(double_tap_modifier): Tap a specific left/right modifier (left_shift,right_shift,left_control,right_control,left_option,right_option,left_command,right_command, orfn) twice withindouble_tap_window_ms.
Supported Actions (8 kinds + 15 built-ins)
- Cursor, Word & Line Navigation (
directional):left,right,up,down,word_forward(⌥→),word_back(⌥←),home(⌘←),end(⌘→). - Multi-Line Vertical Jump (
jump): Jumpupordownbycountlines (>= 1, e.g.10lines viabuiltin.jump_up_10/builtin.jump_down_10). - Editing & Utility (
independent):backspace(composes with⌥/⌘),next_line(⌘→then↵— opens a new line below from mid-line),insert_quotes(types"""|"""triple quotes with cursor centered),toggle_caps_lock, andnoop(swallows the shortcut cleanly). - Deterministic Input Source / IME Switching (
input_source): Switches directly to a specific Carbon TIS input source ID (e.g.com.apple.keylayout.ABCor a Chinese/Japanese/Korean IME), with optional CJKV reliability workarounds (cjkv_fix_strategy:none,shortcut_simulation,switching_focus). - Synthesized Key Combos (
key_combo): Sends any key withCtrl,Option(with_alt),Cmd, and/orShift(with_target_shift), e.g.⌘⇧4screenshot,⌃⇥tab switch,⌘Kcommand palette. - Launch / Focus / Toggle-Hide Apps (
open_app): Launches or focuses an app by macOSbundle_id. By default (hide_if_frontmost: true), pressing the shortcut again while the app is frontmost hides it (⌘Hquake-style toggle). - Shell Commands (
command): Runs any shell snippet asynchronously via/bin/sh -c "<command>"(open URLs, Raycast deeplinks, AppleScript, CLI scripts, shortcuts). - Push-to-Talk Held Modifier (
hold_modifier): Holds a side-specific modifier (left/rightshift/control/option/command— notfn) down for as long as aCaps + Keychord is held, releasing on key-up. Ideal for voice dictation / push-to-talk apps (Wispr Flow, Superwhisper, Typeless).
Per-App Conditional Bindings & Low-Level Key Remaps
- Per-App Rules (
bindings[]): Any trigger can attach orderedfrontmost_apprules (includeallowlist and/orexcludedenylist of bundle IDs) to run app-specific actions or disable a global mapping (builtin.noop) in specific apps (such as Terminal, Xcode, Emacs, or games). - Right-Modifier → F13–F19 Remaps (
key_remapsinapp_config.yml): Repurpose seldom-used right-hand modifiers (right_command,right_option,right_control,right_shift) viahidutilinto conflict-free function keys (f13–f17,f19) for global hotkeys across macOS, while keeping all left-hand modifiers intact. - Not Supported: Remapping arbitrary standalone keys unrelated to
CapsLock/modifiers, mouse button remapping, bindingF18(129), or holdingfnviahold_modifier.
Critical Safety Rules
- NEVER guess numeric
keyortarget_keycodes: HyperCapslock uses JavaScriptKeyboardEvent.keyCode(UInt16) numbers (e.g.,A=65,H=72,4=52,Space=32,Enter=13,Esc=27,;=186), NOT macOSCGKeyCode(kVK_*) and NOT HID usage codes. Always look up./references/keycodes.mdor runcli list-keys. - NEVER use
129(F18):129(F18/0x4F) is reserved as HyperCapslock's internalCapsLock → F18target.cli validateand the engine reject129everywhere. - NEVER use
fninhold_modifier:modifier: fnworks only intrigger: { kind: double_tap_modifier, modifier: fn }. It is forbidden inaction: { kind: hold_modifier, ... }. - NEVER wipe existing user mappings or unknown keys: Always read the user's current
action_mappings.yml/app_config.ymlfirst. Modify only what the user asked for, keeping all existing customactions, unrelatedmappings, and any unrecognized top-level or per-entry YAML keys intact. - Prefer
builtin.*IDs and reusableactions[]IDs:- Reference built-in actions via their 15 permanent
builtin.*IDs (never invent or rename abuiltin.*ID). - Define custom actions in top-level
actions:with a fresh UUID (e.g., fromuuidgen) and reference them viaaction_id—especially when shared across multiple triggers or per-appbindings. - Never use the retired
builtin.switch_input_sourceorindependent: switch_input_sourcetombstone (it is a no-op); always usekind: input_sourcewith a realinput_source_id.
- Reference built-in actions via their 15 permanent
- NEVER guess
input_source_idorbundle_id: Runcli list-input-sourcesto inspect exact Carbon TIS IDs on this Mac, and verify app bundle IDs viaosascript -e 'id of app "AppName"'ormdls -name kMDItemCFBundleIdentifier -r "/Applications/AppName.app".
CLI Interface
Resolving the Binary (<BIN>)
- If the user prompt specifies a binary path, use it.
- Otherwise check if an instance is running (
pgrep -lf "HyperCapslock(-Dev)?\.app/Contents/MacOS/") or default to:- Release:
/Applications/HyperCapslock.app/Contents/MacOS/HyperCapslock- Default
data_dir:~/Library/Application Support/me.xueshi.hypercapslock
- Default
- Dev:
<DerivedData>/Build/Products/Debug/HyperCapslock-Dev.app/Contents/MacOS/HyperCapslock-Dev- Default
data_dir:~/Library/Application Support/me.xueshi.hypercapslock.debug
- Default
- Release:
CLI Subcommands
Syntax: "<BIN>" cli <subcommand> [--data-dir <dir>] [--json]
| Subcommand | Purpose |
|---|---|
cli info | Prints active data_dir, action_mappings.yml & app_config.yml paths, bundled SKILL.md / SKILL.zh.md paths, running app status/PID, active mapping & custom-action counts, and backup count. |
cli list-keys | Prints every valid key name ↔ numeric JS keyCode (UInt16), all 9 ModifierKey values, reserved F18 (129), and key_remaps enums. |
cli list-builtins | Lists all 15 permanent builtin.* action IDs with English and Chinese descriptions. |
cli list-input-sources | Lists installed/enabled macOS Carbon TIS input sources (id, name, isCurrent, isCJKV) on this Mac. |
cli validate [--mappings <path>] [--app-config <path>] [--strict] | Strictly validates YAML syntax, schema, JS keyCodes (!= 129), hold_modifier != fn, action_id resolution, duplicate triggers/IDs, and app_config bounds (hud_duration_ms: 300...6000, double_tap_window_ms: 100...500). Warns on missing local input sources or app bundle_ids (--strict turns warnings into errors). |
cli apply [--mappings <path>] [--app-config <path>] [--strict] | Recommended transactional command: validates staged file(s) → backs up replaced config to <data_dir>/backups/<name>-<YYYYMMDD-HHmmss>-<UUID>.yml → writes atomically → triggers live hot-reload in the running app with synchronous IPC ack. |
cli reload [--strict] | Validates on-disk files in <data_dir>, backs up the previous in-memory version with <timestamp>-<UUID> if changed on disk, and hot-reloads the running app (engine + open SwiftUI UI). |
cli backups [--kind mappings|app-config] | Lists all <name>-<YYYYMMDD-HHmmss>-<UUID>.yml snapshots in <data_dir>/backups/ (newest first). |
cli rollback [--latest | --file <filename-or-path>] [--kind mappings|app-config] | Backs up the current file with <timestamp>-<UUID>, restores the selected snapshot (defaults to --latest), and hot-reloads immediately. |
cli install-skill [--target all|claude|codex|cursor|antigravity|windsurf|cline|copilot] | Installs the bundled skill into ~/.agents/skills/hypercapslock and symlinks it into local coding agents. |
cli prompt [--lang zh|en] | Prints the localized AI bootstrap prompt with runtime paths for this Mac. |
Step-by-Step Golden Workflow
Always follow this 4-step transactional workflow when reading or changing HyperCapslock configuration:
Step 1: Inspect Environment & Read Existing YAML
bashBIN="/Applications/HyperCapslock.app/Contents/MacOS/HyperCapslock" "$BIN" cli info --json
- Read the existing
action_mappings.ymland/orapp_config.ymlat the exact paths reported bycli info. - If configuring input sources, run
"$BIN" cli list-input-sources. - Consult
./references/keycodes.md(or"$BIN" cli list-keys) and./references/schema-and-actions.mdfor exact schemas and numeric JSkeyCodes.
Step 2: Stage Updated YAML to a Temporary File
- Construct the updated YAML preserving all existing custom
actions, unrelatedmappings, and unknown keys. - Write the complete staged YAML to a temporary path (e.g.
/tmp/hypercapslock_mappings_staged.ymlor/tmp/hypercapslock_app_config_staged.yml) rather than editing<data_dir>directly.
Step 3: Validate & Apply Transactionally
bash"$BIN" cli apply --mappings /tmp/hypercapslock_mappings_staged.yml --json # Or when updating app settings too: # "$BIN" cli apply --mappings /tmp/hypercapslock_mappings_staged.yml --app-config /tmp/hypercapslock_app_config_staged.yml --json
- If validation fails, fix the staged file using the reported diagnostics and re-run
cli apply(the user's live config has not been touched). - (If a file in
<data_dir>was already edited directly on disk, run"$BIN" cli validatefollowed by"$BIN" cli reload.)
Step 4: Verify Reload Ack & Report to User
- Confirm exit code
0and check thereloadacknowledgment in the CLI output (if the app is not currently running, inform the user that the validated config was written and will activate when HyperCapslock launches). - Remove temporary staged file(s) (
rm -f /tmp/hypercapslock_*_staged.yml). - Report to the user:
- The exact shortcuts/settings added or modified.
- The automatic backup snapshot created in
<data_dir>/backups/(<name>-<YYYYMMDD-HHmmss>-<UUID>.yml). - How to revert instantly if needed (
"$BIN" cli rollback --latest --kind mappings).


