Skip to main content

Prerequisites

Before you begin, ensure you have the following installed:
  • Python 3.10+: Swarms requires Python 3.10 or higher
  • Git: For version control
  • pip, uv, or poetry: For package management

Installation Methods

Using pip

The simplest way to install Swarms for development:
uv is a fast Python package installer and resolver, written in Rust.

Using poetry

From Source (For Contributors)

If you’re planning to contribute to Swarms, you should install from source:

Environment Configuration

Create a .env file in your project root with the necessary API keys and configuration:
Learn more about environment configuration in the Environment Configuration Guide.

API Keys

You’ll need API keys from various providers depending on which models you plan to use:

Project Structure

Understanding the project structure will help you navigate and contribute effectively:
  • swarms/: Contains all the source code for the library
    • agents/: Agent implementations and base classes
    • structs/: Swarm orchestration structures (SequentialWorkflow, AgentRearrange, etc.)
    • tools/: Tool implementations and base classes
    • prompts/: System prompts and prompt templates
    • utils/: Utility functions and helpers
  • examples/: Includes example scripts and notebooks demonstrating how to use the library
  • tests/: Unit tests for the library
  • docs/: Documentation files and guides

Development Workflow

1. Fork and Clone

First, fork the repository on GitHub and clone your fork:

2. Create a Branch

Create a new branch for your feature or bug fix:

3. Make Changes

Make your changes to the codebase. Ensure you follow the coding standards.

4. Run Tests

Before submitting your changes, run the test suite to ensure everything works:

5. Lint Your Code

Ensure your code follows PEP 8 standards:

6. Commit Your Changes

Write clear and descriptive commit messages:

7. Push to Your Fork

8. Create a Pull Request

Go to the original repository on GitHub and create a pull request from your fork.

Testing Guidelines

Writing Tests

All new features and bug fixes must include appropriate tests:

Test Organization

  • Place tests in the tests/ directory
  • Mirror the structure of the swarms/ directory
  • Use descriptive test names that explain what is being tested
  • Group related tests in the same file

Running Specific Tests

Documentation

Building Documentation Locally

If you’re contributing to documentation:

Writing Documentation

When adding new features, always update the documentation:
  • Add docstrings to all public classes and functions
  • Update relevant documentation pages in docs/
  • Add examples demonstrating the new feature
  • Update the API reference if necessary

Debugging Tips

Enable Verbose Logging

Use Interactive Mode

Check Logs

Swarms provides comprehensive logging. Check the logs in your workspace directory for debugging information.

Common Issues and Solutions

Import Errors

If you encounter import errors, ensure you’ve installed all dependencies:

API Key Errors

Make sure your .env file is properly configured with valid API keys.

Test Failures

If tests fail:
  1. Check that you have the latest version of dependencies
  2. Ensure your environment variables are set correctly
  3. Run tests in verbose mode for more details: pytest -v

Getting Help

If you encounter any issues during development:

Ready to Contribute?

Now that you have your development environment set up, check out the Contributing Guide to learn how to make your first contribution!