Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
athola avatar

Authentication Patterns

  • 93 installs
  • 325 repo stars
  • Updated August 2, 2026
  • athola/claude-night-market

Authentication-patterns is an agent skill that standardizes interactive CLI authentication with caching before workflow commands run.

About

Authentication-patterns is an agent skill from the Claude Night Market / Leyline line that shows how to integrate interactive authentication into existing bash workflows. Solo builders hitting GitHub, or similar services, from custom commands often copy-paste auth checks that exit with opaque errors; this skill replaces that with sourced interactive_auth modules and ensure_auth gates. Examples contrast the old manual gh auth status pattern with cached interactive auth, then apply it to PR review and issue creation flows that call gh and the GitHub API. Benefits called out include user prompts when credentials are missing, short-lived status caching to avoid repeated checks, day-long session persistence for local dev, and CI compatibility when tokens are injected. The pattern is meant to be copied at the top of any workflow that needs network-backed CLIs so agents consistently authenticate before fetching PRs, comments, or creating issues.

  • ensure_auth pattern replaces brittle manual gh auth status checks
  • Auth status cached for 5 minutes with session persistence up to 24 hours
  • Works in CI/CD when GITHUB_TOKEN is provided alongside interactive login flows
  • Documented wiring for PR review and create-issue style slash commands
  • Pre-flight check at workflow start for any external service access

Authentication Patterns by the numbers

  • 93 all-time installs (skills.sh)
  • Ranked #836 of 2,715 Automation & Workflows skills by installs in the Skillselion catalog
  • Security screen: HIGH risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/athola/claude-night-market --skill authentication-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs93
repo stars325
Security audit2 / 3 scanners passed
Last updatedAugust 2, 2026
Repositoryathola/claude-night-market

What it does

Drop interactive GitHub (and similar) authentication with caching into bash workflow skills so commands fail fast with clear prompts.

Who is it for?

Best when you're maintaining bash-based agent commands in Leyline-style plugins and want one reusable auth module instead of per-script checks.

Skip if: Pure in-app OAuth flows or languages that never shell out to gh-style CLIs without adapting the bash module.

When should I use this skill?

At the start of any bash workflow or agent command that requires GitHub or external CLI authentication.

What you get

Workflows source ensure_auth helpers so users get guided login, cached auth for repeat commands, and reliable execution in local and token-based CI runs.

  • Reusable ensure_auth integration in command scripts
  • Documented before/after patterns for PR review and issue creation flows

By the numbers

  • Auth status cached for 5 minutes
  • Session persistence up to 24 hours

Files

SKILL.mdMarkdownGitHub ↗

Table of Contents

Authentication Patterns

Overview

Common authentication patterns for integrating with external services. Provides consistent approaches to credential management, verification, and error handling.

When To Use

  • Integrating with external APIs
  • Need credential verification
  • Managing multiple auth methods
  • Handling auth failures gracefully

When NOT To Use

  • Project doesn't use the leyline infrastructure patterns
  • Simple scripts without service architecture needs

Authentication Methods

MethodBest ForEnvironment Variable
API KeySimple integrations{SERVICE}_API_KEY
OAuthUser-authenticatedBrowser-based flow
TokenSession-based{SERVICE}_TOKEN
NonePublic APIsN/A

Quick Start

Verify Authentication

from leyline.auth import verify_auth, AuthMethod

# API Key verification
status = verify_auth(
    service="gemini",
    method=AuthMethod.API_KEY,
    env_var="GEMINI_API_KEY"
)

if not status.authenticated:
    print(f"Auth failed: {status.message}")
    print(f"Action: {status.suggested_action}")

Verification: Run the command with --help flag to verify availability.

Smoke Test

def verify_with_smoke_test(service: str) -> bool:
    """Verify auth with simple request."""
    result = execute_simple_request(service, "ping")
    return result.success

Verification: Run pytest -v to verify tests pass.

Standard Flow

Step 1: Check Environment

def check_credentials(service: str, env_var: str) -> bool:
    value = os.getenv(env_var)
    if not value:
        print(f"Missing {env_var}")
        return False
    return True

Verification: Run the command with --help flag to verify availability.

Step 2: Verify with Service

def verify_with_service(service: str) -> AuthStatus:
    result = subprocess.run(
        [service, "auth", "status"],
        capture_output=True
    )
    return AuthStatus(
        authenticated=(result.returncode == 0),
        message=result.stdout.decode()
    )

Verification: Run the command with --help flag to verify availability.

Step 3: Handle Failures

def handle_auth_failure(service: str, method: AuthMethod) -> str:
    actions = {
        AuthMethod.API_KEY: f"Set {service.upper()}_API_KEY environment variable",
        AuthMethod.OAUTH: f"Run '{service} auth login' for browser auth",
        AuthMethod.TOKEN: f"Refresh token with '{service} token refresh'"
    }
    return actions[method]

Verification: Run the command with --help flag to verify availability.

Integration Pattern

# In your skill's frontmatter
dependencies: [leyline:authentication-patterns]

Verification: Run the command with --help flag to verify availability.

Interactive Authentication (Shell)

For workflows requiring interactive authentication with token caching and session management:

# Source the interactive auth script
source plugins/leyline/scripts/interactive_auth.sh

# Ensure authentication before proceeding
ensure_auth github || exit 1
ensure_auth gitlab || exit 1
ensure_auth aws || exit 1

# Continue with authenticated operations
gh pr view 123
glab issue list
aws s3 ls

Features:

  • ✅ Interactive OAuth flows for GitHub, GitLab, AWS, and more
  • ✅ Token caching (5-minute TTL)
  • ✅ Session persistence (24-hour TTL)
  • ✅ CI/CD compatible (auto-detects non-interactive environments)
  • ✅ Multi-service support

See modules/interactive-auth.md for complete documentation.

Detailed Resources

  • Auth Methods: See modules/auth-methods.md for method details
  • Verification: See modules/verification-patterns.md for testing patterns
  • Interactive: See modules/interactive-auth.md for shell-based auth flows

Exit Criteria

  • Credentials verified or clear failure message
  • Suggested action for auth failures
  • Smoke test confirms working auth

Related skills

How it compares

Use as a workflow template layer, not a hosted identity provider or MCP auth server.

FAQ

Who is authentication-patterns for?

Developers wiring Claude Night Market / Leyline bash commands that need GitHub or similar CLI access with interactive fallback.

When should I use authentication-patterns?

Use it in Build (integrations) when authoring PR or issue commands; in Ship (review) before gh pr view or API calls; in Operate when automation scripts need GITHUB_TOKEN in CI.

Is authentication-patterns safe to install?

It runs shell auth helpers and may prompt for credentials; review the Security Audits panel on this page and scope tokens to least privilege.

Automation & Workflowsintegrationsdevopsgit

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.