agentleFS
roie9876roie9876/clawpilot-skills/sso-watcher/SKILL.md

sso-watcher

Skill4 starsChanged 7 months agoMITView on GitHub

Install and manage the Hammerspoon-based SSO auto-picker for Clawpilot (or any Electron app). Automatically dismisses the Microsoft Entra ID account picker by selecting the configured account and clicking Continue. macOS only. Triggers include: 'sso watcher', 'install sso', 'sso auto-picker', 'setup sso', 'hammerspoon sso', or any request to auto-dismiss the SSO login dialog.

  • Installs packages

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the install script with the target Microsoft account email:

    line 38
  2. Distinctive:

    After installation, Hammerspoon needs Accessibility access:

    line 60
  3. Very specific:

    After editing, reload Hammerspoon: click the Hammerspoon menu bar icon → Reload Config, or run hs -c "hs.reload()" from terminal.

    line 90
  4. Distinctive:

    Check Hammerspoon is running: look for the hammer icon in the menu bar

    line 97
  5. Distinctive:

    When the user asks to install or manage the SSO watcher via Clawpilot:

    line 115

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/sso-watcher — Hammerspoon SSO Auto-Picker

Automatically dismisses the Microsoft Entra ID / SSO account picker modal that appears inside Clawpilot (or any Electron app) by selecting the configured account and clicking Continue.

macOS only — uses Hammerspoon for Accessibility API access with zero TCC headaches.

How It Works

  1. The SSO account picker is NOT inside Clawpilot — it's rendered by AppSSOAgent (com.apple.AppSSOAgent), the macOS Enterprise SSO broker from Company Portal
  2. Hammerspoon polls AppSSOAgent's AX (Accessibility) tree every 3 seconds
  3. Also triggers on any app activation (SSO agent may pop up for any app)
  4. Looks for SSO dialog markers: "Accounts found", "Sign in to your account", etc.
  5. Finds the AXRow containing the configured email and clicks it
  6. Waits 0.8s then clicks the "Continue" button
  7. 15-second cooldown after each successful click to avoid loops

Files

FileLocationPurpose
sso-watcher.lua~/.hammerspoon/sso-watcher.luaMain Hammerspoon module
sso-watcher-config.lua~/.hammerspoon/sso-watcher-config.luaConfiguration (account, app name, intervals)
init.lua~/.hammerspoon/init.luaHammerspoon entry point (loads the module)
Log~/Scripts/sso-watcher-hammerspoon.logRuntime log

Installation

Run the install script with the target Microsoft account email:

bash "$HOME/customer-skills/sso-watcher/install.sh" user@microsoft.com

Or for a custom app name:

bash "$HOME/customer-skills/sso-watcher/install.sh" user@microsoft.com "MyElectronApp"

The installer:

  1. Installs Hammerspoon via Homebrew (if missing)
  2. Copies sso-watcher.lua to ~/.hammerspoon/
  3. Creates config with the account email
  4. Adds require("sso-watcher") to ~/.hammerspoon/init.lua
  5. Enables Hammerspoon auto-launch at login
  6. Launches/reloads Hammerspoon

macOS Permissions

After installation, Hammerspoon needs Accessibility access:

System Settings → Privacy & Security → Accessibility → Toggle ON: Hammerspoon

Without this, the watcher cannot read or interact with the SSO dialog.

Uninstallation

bash "$HOME/customer-skills/sso-watcher/uninstall.sh"

Removes the module, config, and log. Does NOT uninstall Hammerspoon itself.

Configuration

Edit ~/.hammerspoon/sso-watcher-config.lua:

return {
    account       = "user@microsoft.com",   -- email to auto-select
    poll_interval = 3,                       -- seconds between checks
    cooldown      = 15,                      -- seconds after successful click
    log_file      = os.getenv("HOME") .. "/Scripts/sso-watcher-hammerspoon.log",
}

The watcher always monitors AppSSOAgent (com.apple.AppSSOAgent) — the system SSO broker. No need to configure which app triggers the SSO dialog.

After editing, reload Hammerspoon: click the Hammerspoon menu bar icon → Reload Config, or run hs -c "hs.reload()" from terminal.

Troubleshooting

Watcher not triggering

  1. Check Hammerspoon is running: look for the hammer icon in the menu bar
  2. Check Accessibility: System Settings → Privacy & Security → Accessibility → Hammerspoon must be ON
  3. Check logs: tail -f ~/Scripts/sso-watcher-hammerspoon.log
  4. Check config: cat ~/.hammerspoon/sso-watcher-config.lua — verify the email is correct
  5. Reload: Click Hammerspoon menu bar → Reload Config

"SSO markers found but account element not found"

The dialog was detected but your email wasn't in the AX tree yet. This is usually a timing issue — the watcher will retry on the next poll (3s).

Account clicked but Continue button not found

The 0.8s delay may not be enough on a slow machine. Edit the config to increase cooldown or modify sso-watcher.lua to increase the doAfter delay.

Skill Invocation

When the user asks to install or manage the SSO watcher via Clawpilot:

Install (first time on a new Mac)

  1. Detect the user's Microsoft email:
    m365_get_my_profile() → email
    Or ask the user.
  2. Run the installer:
    bash "$HOME/customer-skills/sso-watcher/install.sh" "user@microsoft.com"
  3. Remind the user to grant Accessibility to Hammerspoon.

Check status

pgrep -x Hammerspoon && echo "Running" || echo "Not running"
cat ~/.hammerspoon/sso-watcher-config.lua
tail -5 ~/Scripts/sso-watcher-hammerspoon.log

Change account

bash "$HOME/customer-skills/sso-watcher/install.sh" "newemail@microsoft.com"

Uninstall

bash "$HOME/customer-skills/sso-watcher/uninstall.sh"

Prerequisite Auto-Install

This skill has no sibling skill dependencies. It only requires:

ToolCheckInstall
Homebrewcommand -v brewhttps://brew.sh
Hammerspoonls /Applications/Hammerspoon.appbrew install --cask hammerspoon

The install script handles Hammerspoon installation automatically.

Platform Note

This skill is macOS only. Hammerspoon does not exist on Linux or Windows. On other platforms, the SSO picker must be handled differently (e.g., browser extension, AutoHotkey on Windows).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.