flipswitch-setup

📁 flipswitch-io/skills 📅 7 days ago
4
总安装量
3
周安装量
#48638
全站排名
安装命令
npx skills add https://github.com/flipswitch-io/skills --skill flipswitch-setup

Agent 安装分布

opencode 3
codex 3
github-copilot 3
claude-code 3
gemini-cli 3
amp 1

Skill 文档

Set up the Flipswitch feature flag SDK in this project.

IMPORTANT: Execute these steps directly

Do NOT create helper tasks, spawn subagents, or delegate work. Execute each step in sequence, calling the MCP tools directly and handling results inline.

Step 0: Verify MCP Server Configuration

Call the authenticate MCP tool immediately to test connectivity.

  • If it succeeds (returns auth status or URL+code): ✅ MCP server is configured. Proceed to Step 1.
  • If it fails with “tool not found” or “unknown tool”: ❌ MCP server is NOT configured. Provide these instructions:
    To configure the Flipswitch MCP server, run this command in your terminal:
    
    claude mcp add --scope user --transport http flipswitch https://mcp.flipswitch.io/mcp
    
    This will add the MCP server to your ~/.claude.json configuration file (user scope).
    After running this command, restart Claude Code or run: /mcp reload
    
    Stop here. User must configure and retry.
  • If it fails with a network error: ⚠️ MCP server is configured but unreachable. Ask user to check internet connection.

Step 1: Check Authentication Status

After successful authenticate call, check the result:

  • Already authenticated: Display the auth status and proceed to Step 2.
  • Device code provided: Show the user the URL and device code. Tell them to visit the URL, enter the code, and authorize. Then immediately call authenticate again to confirm.

Step 2: Detect Project Language

Use Glob to find language markers in the project root:

  • Check for package.json or tsconfig.json → javascript
  • Check for requirements.txt, pyproject.toml, setup.py, or Pipfile → python
  • Check for go.mod → go
  • Check for pom.xml, build.gradle, or build.gradle.kts → java

If you find files for multiple languages or none, ask the user to specify using AskUserQuestion with options: “JavaScript”, “Python”, “Go”, “Java”, “Other”.

For JavaScript projects only: Also determine if it’s a web or server (Node.js) project:

  • If next.config.js, vite.config.js, webpack.config.js, or similar build config exists → web
  • If it’s a Next.js/Remix/similar full-stack framework → ask the user if they want snippets for web, server, or both
  • If Dockerfile or docker-compose.yml exists and no obvious web build config → likely server
  • If uncertain, ask the user: “Is this a web app (browser), Node.js server, or full-stack?”. Use AskUserQuestion with options: “Web browser”, “Node.js server”, “Both (I’ll use both snippets)”

Save the selected language and JS environment (if applicable).

Step 3: Get Organizations and Projects

Call list_organizations MCP tool with no arguments.

  • If only 1 org: Use it automatically.
  • If multiple orgs: Use AskUserQuestion to let user pick one.

Save the selected org ID.

Then call list_projects MCP tool with organizationId set to the saved org ID.

  • If only 1 project: Use it automatically.
  • If multiple projects: Use AskUserQuestion to let user pick one.

Save the selected project ID.

Step 4: Get Environments

Call list_environments MCP tool with organizationId and projectId set to saved values.

  • If an environment named “Development” exists: Use it automatically.
  • Otherwise: Use AskUserQuestion to let user pick an environment.

Save the selected environment ID.

Step 5: Get SDK API Key

Call get_sdk_api_key MCP tool with organizationId, projectId, and environmentId set to saved values.

The tool will return an API key. Save this key — you’ll need it in the next step.

Step 6: Create Example Flag (Optional)

Call create_flag MCP tool with:

  • organizationId: saved org ID

  • projectId: saved project ID

  • key: “my-feature”

  • name: “My Feature”

  • flagValueType: “Boolean”

  • If successful: ✅ Flag created.

  • If it fails with “key already exists” or similar: That’s fine, the flag already exists. Continue to next step.

  • If it fails for another reason: Report the error but continue.

Step 7: Get SDK Setup Snippet

Call get_sdk_setup_snippet MCP tool with:

  • language: saved language from Step 2
  • apiKey: saved API key from Step 5
  • flagKey: “my-feature”
  • If language is javascript: also set jsEnvironment based on detection from Step 2 (e.g., “web” or “server”)

The tool will return install command, init code, and evaluation code. Display these to the user.

Step 8: Install SDK

Tell the user to run the install command returned from Step 7:

  • javascript (web): npm install @flipswitch-io/sdk @openfeature/web-sdk
  • javascript (server): npm install @flipswitch-io/sdk @openfeature/js-sdk
  • python: pip install flipswitch-sdk
  • go: go get github.com/flipswitch-io/go-sdk
  • java: Show the Maven/Gradle dependency from the snippet

Then ask the user to run the command and confirm when done.

Step 9: Write Initialization Code

Get the init code from Step 7’s result. Based on the language, create a file:

  • javascript: src/flipswitch.ts (or .js if not TypeScript)
  • python: flipswitch_config.py
  • go: flipswitch.go
  • java: FlipswitchConfig.java

Use the Write tool to create the file with the init code from Step 7.

Display the file path to the user.

Step 10: Summary

Show the user:

  • ✅ SDK installed
  • ✅ Initialization code written to <file_path>
  • ✅ Example flag my-feature created
  • Link: https://app.flipswitch.io
  • Next steps: Enable the flag in the dashboard, then use the evaluation code from Step 7 in your application