Skip to main content

Blocks CLI

A CLI tool for Blocks, a platform for writing custom AI-enabled codebase automations in Python. Leverage a full codebase-aware API. Automatically trigger automations from GitHub, Slack, and other providers.

Status: Private alpha. Please keep your SDK updated to get the latest fixes and features.

Prerequisites

  • Python >= 3.9
  • pip available in your environment

Installation

Blocks CLI is packaged with the Python SDK.

pip install blocks-sdk

Verify installation:

blocks --help

Quick Start

  1. Initialize in your repository (creates a .blocks directory and optionally saves your API key):
# Option A: Provide key now
blocks init --key <your-api-key>

# Option B: Initialize, then configure later
blocks init
blocks configure --key <your-api-key>
  1. Create a new automation scaffold:
blocks create my_automation

This generates .blocks/my_automation/ with a starter main.py and requirements.txt.

  1. Edit the generated automation to set an event and repository:
# .blocks/my_automation/main.py
from blocks import task, on

@task(name="my_automation")
@on("github.pull_request", repos=["MyOrg/MyRepo"])
def my_automation(event):
    print(event)
  1. Test the automation locally with a sample event:
blocks test .blocks/my_automation/main.py
# If your file defines multiple automations, specify one by name:
# blocks test .blocks/my_automation/main.py --name my_automation
  1. Push the automation to Blocks:
blocks push .blocks/my_automation/main.py

Command Reference

  • blocks init [--key <api-key>]: Initializes Blocks in the current repo by creating a .blocks directory. When --key is provided, verifies and saves your API key.
  • blocks configure --key <api-key>: Verifies and saves/updates your API key.
  • blocks create <name>: Creates a new automation under .blocks/<name>/ with a starter template and requirements.txt.
  • blocks test <file> [--name <automation>]: Loads the automation from <file>, fetches a sample event for the configured trigger, and invokes it locally.
  • blocks push <file>: Packages dependencies and source, uploads the bundle, registers the automation, and triggers a build.

Naming Rules

  • Automation names must start with a letter and can include letters, numbers, dashes, and underscores.
  • Example valid names: my_automation, code-reviewer, build_123.

Troubleshooting

  • Already initialized: If .blocks exists, blocks init will report it. Use blocks configure --key <api-key> to update your key.
  • Invalid API key: Ensure your key is correct. You can manage keys at https://blocks.team
  • Missing event: The @on("...") decorator must specify a supported event. See events at https://docs.blocks.team/docs/events
  • Multiple automations in a file: Use --name <automation> with blocks test to choose one.

Upgrading

pip install -U blocks-sdk

License

AGPL-3.0. See LICENSE for details.

Metadata

Release files for blocks-cli 0.1.43

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blocks-cli 0.1.43
File Size Uploaded
blocks_cli-0.1.43.tar.gz 26.4 kB Details

Release files / blocks_cli-0.1.43.tar.gz

Download URL blocks_cli-0.1.43.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
62b9f1645ba3e7b1b4187483a098d524c9cdfbc767c99a90ee74b88a8587aa96
BLAKE2b-256 checksum
How to use checksums
cb028b0c455da4358693dd5da081c3c1f9f160d7b01a4cef9f33b328fceca776
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

0.1.43 This release

1 release file

0.1.42

1 release file

0.1.41

1 release file

0.1.40

1 release file

0.1.39

1 release file

0.1.38

1 release file

0.1.37

1 release file

0.1.36

1 release file

0.1.35

1 release file

0.1.34

1 release file

0.1.33

1 release file

0.1.32

1 release file

0.1.31

1 release file

0.1.30

1 release file

0.1.29

1 release file

0.1.28

1 release file

0.1.27

1 release file

0.1.26

1 release file

0.1.25

1 release file

0.1.24

1 release file

0.1.23

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page