AgentSkillsCN

galaxy-context

Galaxy 项目开发规范与技能路由指南。在 Galaxy 代码库中工作时,务必加载此技能。根据需求将路由导向相应技能:若需进行数据库/ Alembic/Schema 变更,请使用 /db-migration;若要创建 REST API 端点或 FastAPI 路由器,请使用 /api-endpoint;若要运行或编写测试,则可选择 /testing。如遇代码库架构相关问题,可借助 galaxy-explorer 代理获取专业解答。

SKILL.md
--- frontmatter
name: galaxy-context
description: >
  Galaxy project development conventions and skill routing guide.
  ALWAYS load this skill when working in a Galaxy codebase.
  Routes to appropriate skills: use /db-migration for database/Alembic/schema changes,
  /api-endpoint for creating REST API endpoints/FastAPI routers,
  /testing for running or writing tests.
  Use galaxy-explorer agent for codebase architecture questions.
user-invocable: false

Galaxy Development Context & Skill Routing

This skill provides essential Galaxy conventions and routing guidance to help you proactively use the right Galaxy skills and agents.

Automatic Skill Invocation - CRITICAL

You should PROACTIVELY invoke Galaxy skills when you detect relevant tasks, without waiting for explicit user requests. Match user intent to skills below.


Skill Routing Guide

1. Database Operations → /db-migration

Invoke when user mentions:

  • "database", "schema", "migration", "Alembic"
  • "add column", "create table", "modify database", "database version"
  • "upgrade database", "downgrade database", "migration error"
  • SQL model changes in lib/galaxy/model/__init__.py
  • Alembic revision files in lib/galaxy/model/migrations/alembic/versions_gxy/

Examples:

  • "I need to add a new table for credentials" → /db-migration create
  • "How do I add a column to the workflow table?" → /db-migration create
  • "The database won't upgrade" → /db-migration troubleshoot
  • "Check if migration is needed" → /db-migration status

Actions:

  • create - Creating new migrations after model changes
  • upgrade - Upgrading database to latest version
  • downgrade - Rolling back migrations
  • status - Checking database version vs codebase
  • troubleshoot - Diagnosing migration errors

2. API Development → /api-endpoint

Invoke when user mentions:

  • "API", "endpoint", "REST", "route", "router"
  • "FastAPI", "Pydantic", "schema", "request/response model"
  • "create endpoint for...", "add API for...", "new endpoint"
  • Files in lib/galaxy/webapps/galaxy/api/
  • Files in lib/galaxy/schema/

Examples:

  • "Create an API endpoint for managing credentials" → /api-endpoint credentials
  • "I need a REST API for workflows" → /api-endpoint workflows
  • "Add a new route to handle..." → /api-endpoint [resource-name]

Action:

  • Always pass the resource name as argument (e.g., /api-endpoint credentials)
  • Guides through: Pydantic schemas → Manager logic → FastAPI router → Tests

3. Testing Operations → /testing

Invoke when user mentions:

  • "test", "tests", "pytest", "run_tests.sh"
  • "write tests", "add test", "test this feature"
  • "test failure", "test error", "tests are failing"
  • "ApiTestCase", "integration test", "unit test", "functional test"
  • Files in test/, lib/galaxy_test/

Examples:

  • "Run the integration tests" → /testing run
  • "Write tests for this new API" → /testing write
  • "How do I test this endpoint?" → /testing api
  • "The tests are failing" → /testing run (to diagnose)

Actions:

  • run - Running tests (unit, integration, selenium)
  • write - Writing new tests (guides through patterns)
  • api - API testing patterns (ApiTestCase, fixtures)

4. Codebase Architecture Questions → galaxy-explorer Agent

Use Task tool with subagent_type="galaxy-explorer" when user asks:

  • "Where is X implemented?"
  • "How does Y work?"
  • "What's the architecture of Z?"
  • "Find the component that handles..."
  • "Show me examples of..."
  • Broad exploration questions about code structure

Examples:

  • "Where is authentication handled?" → Spawn galaxy-explorer
  • "How do workflows execute?" → Spawn galaxy-explorer
  • "What's the testing structure?" → Spawn galaxy-explorer

Why use galaxy-explorer:

  • Knows Galaxy architecture deeply
  • Avoids reading large files completely
  • Can answer multi-file architectural questions efficiently
  • Understands Galaxy conventions and patterns

Do NOT use galaxy-explorer for:

  • Specific needle queries (use Grep/Glob directly)
  • Reading known file paths (use Read directly)
  • Simple file searches (use Glob directly)

Critical Galaxy Conventions

Testing: ALWAYS use run_tests.sh

NEVER run pytest directly - Galaxy's test suite requires special setup:

bash
# Correct
./run_tests.sh -integration test/integration/test_credentials.py

# Wrong - will fail or miss fixtures
pytest test/integration/test_credentials.py

Why:

  • Sets up Galaxy test database
  • Configures Galaxy-specific fixtures
  • Manages test isolation
  • Handles Galaxy configuration

Large Files: NEVER Read Completely

These files will exhaust your token budget if read entirely:

  • client/src/api/schema/schema.ts (46,529 lines) - Auto-generated
  • lib/galaxy/model/__init__.py (12,677 lines) - Core models
  • lib/galaxy/tools/__init__.py (4,857 lines) - Tool framework
  • lib/galaxy/schema/schema.py (4,184 lines) - API schemas

Instead:

  • Use Grep with specific patterns
  • Read with offset/limit to get relevant sections
  • Use galaxy-explorer agent for architectural understanding

Manager Pattern

Business logic lives in manager classes:

  • Location: lib/galaxy/managers/
  • Pattern: {Resource}Manager (e.g., WorkflowsManager)
  • Purpose: Separate business logic from API layer

Flow: API Router → Manager → Model

FastAPI Structure

Modern Galaxy API follows FastAPI patterns:

  • Routers: lib/galaxy/webapps/galaxy/api/*.py
  • Schemas: lib/galaxy/schema/*.py (Pydantic models)
  • Tests: lib/galaxy_test/api/test_*.py

Quick Architecture Reference

Backend (Python)

code
lib/galaxy/
├── model/                 # SQLAlchemy models
│   └── migrations/       # Alembic migrations
├── managers/             # Business logic (Manager pattern)
├── schema/               # Pydantic API schemas
├── webapps/galaxy/api/   # FastAPI routers
├── tools/                # Tool execution engine
└── workflow/             # Workflow engine

Frontend (Vue.js)

code
client/src/
├── components/           # Vue components
├── stores/               # Pinia stores
├── composables/          # Composition functions
└── api/                  # API client + generated schemas

Tests

code
test/
├── unit/                 # Fast unit tests
├── integration/          # Integration tests
└── integration_selenium/ # E2E browser tests

lib/galaxy_test/
└── api/                  # API endpoint tests

When to Use Each Approach

Parallel Tool Calls

When operations are independent:

code
Read: lib/galaxy/managers/workflows.py
Read: client/src/stores/workflowStore.ts
Read: test/unit/test_workflows.py

Targeted Searches

For specific patterns in large files:

code
Grep: pattern="class Workflow\(" path="lib/galaxy/model/__init__.py" output_mode="content" -A=20

Galaxy-Explorer Agent

For understanding architecture or locating functionality across multiple files.

Direct Tool Use

For known file paths or simple operations.


Proactive Skill Usage Summary

Before starting implementation:

  1. Detect user intent from their message
  2. Match to skill routing guide above
  3. Invoke appropriate skill BEFORE writing code
  4. Follow skill's guided workflow

Key principle: Skills prevent mistakes by enforcing Galaxy conventions and best practices. Use them proactively rather than reactively.


Additional Notes

  • Galaxy uses Python 3.9+ with FastAPI, SQLAlchemy 2.0, Celery, Pydantic
  • Frontend: Vue.js 2.7 with TypeScript, Pinia, Vite
  • Main branch: dev (not main)
  • Code style: Black (120 chars), isort, Ruff, mypy with strict mode
  • Always use type hints in Python
  • Prefer TypeScript over JavaScript for new frontend code

This context is optimized for the Galaxy codebase as of January 2026.