agentleFS
metratonmetraton/gaia/skills/cli-login/SKILL.md

cli-login

Skill4 starsChanged 4 months agoMITView on GitHub

Use when a CLI command fails because its login is missing or expired (gcloud, gh, gws, Microsoft 365) and the user has to sign in -- "necesito loguearme en gcloud", "la sesion de gcloud expiro", "log me in to gcloud", "reauthenticate gcloud".

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Already held: When gcloud already stores a credential for the account it re-uses it and prints no link.

    line 32
  2. Very specific:

    Expired or stale: If commands with --account <email> still fail after already_signed_in, renew with gaia login start gcloud --account …

    line 36
  3. Very specific:

    Wrong account: If he signs in with another account, gcloud refuses it with "the received credentials were for account [...]" and status …

    line 52
  4. Very specific:

    Not wired yet. gh auth login makes the new account the active one, so adding a GitHub account goes through an isolated gh config directory …

    line 66

≈ “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

CLI Login

A login is the one step only the user can take: he opens a link in his own browser and signs in with his password manager or passkey. The agent's part is to start a login that needs no terminal, put the link in front of him, and confirm afterwards that the session exists. No password and no token passes through the agent, and the user's active account never changes unless he asks.

Why the obvious ways fail

  • A login that waits for pasted input hangs. gcloud auth login --no-launch-browser and --no-browser read a code from the terminal; a dispatched agent has none.
  • A background task can die before the click. The host may stop an agent's background task when the turn ends, and the localhost listener that would receive the browser's answer dies with it.
  • A plain login switches the active account. gcloud auth login activates the new account for every session on the machine, so it asks for a signature; --no-activate adds the account without switching.

Procedure (gcloud)

  1. Start it detached. gaia login start gcloud --account <email> runs gcloud auth login <email> --no-activate in its own session and prints JSON with login_id, state: pending and url. It runs free: it cannot switch the account.
    • Already held. When gcloud already stores a credential for the account it re-uses it and prints no link; the start exits 0 with state: already_signed_in and no url, and gaia login status reports the same. Nothing to click: continue the task.
    • Expired or stale. If commands with --account <email> still fail after already_signed_in, renew with gaia login start gcloud --account <email> --force. It runs gcloud auth login <email> --no-activate --force, returns a fresh link, and is free for the same reason: it never activates the account.
  2. Close the turn on the link. Close NEEDS_INPUT. Put the url in your conclusion for the orchestrator, which hands it to the user as a link with one line: open it, sign in, and reply when done. Say it must be opened in a browser profile, or an incognito window, that holds only the target account: each link allows exactly one sign-in attempt, because gcloud stops listening after the browser's first answer. Record the login_id in key_outputs.
  3. On resume, confirm. gaia login status <login_id> reports pending, complete or failed. complete means gcloud exited cleanly and gcloud auth list shows the account. Then continue the task with --account <email> on the commands that need it.
  4. Wrong account. If he signs in with another account, gcloud refuses it with "the received credentials were for account [...]" and status goes to failed. The link is spent; recover with a fresh gaia login start gcloud --account <email> --force.
  5. On failed or a refused start, report it. A start that reports the copy-code flow means gcloud found no browser it could launch; that machine needs the live interop check, not a retry.

The link redirects to http://localhost:<port>. Windows forwards localhost into WSL, so the browser on Windows reaches the listener whether or not WSL interop is enabled. The login stops on its own after 10 minutes.

Other CLIs

Not wired yet. gh auth login makes the new account the active one, so adding a GitHub account goes through an isolated gh config directory (next slice). gws and Microsoft 365 follow the same start, link, confirm cycle once their launchers exist.

Anti-patterns

  • Running the login in a background Bash task and waiting. The host can stop it before the user clicks; use gaia login start.
  • Reading ~/.config/gcloud to check the session. That path is read-refused; gaia login status and gcloud auth list are the checks.
  • Activating the account to make later commands shorter. Pass --account per command instead.

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.