ZiaGit Documentation

A lightweight, git-like version control system built on Cloudflare Workers and R2 storage.

🚀

Fast & Scalable

Built on Cloudflare's edge network for global low-latency access

🔒

Secure by Default

API key authentication with granular permissions

💰

Cost-Effective

Zero egress fees with R2 storage

🛠️

Git-Compatible

Familiar concepts: commits, branches, trees, blobs

Key Features

  • Content-addressable storage (SHA-256 hashing)
  • Multi-repository support
  • Branch management
  • Commit history and diffs
  • API key authentication with read/write/admin scopes
  • RESTful API
  • CLI tool for easy interaction
  • Integration with Claude Code slash commands

Setup & Authentication

1. Bootstrap Your First API Key

The first time you use ZiaGit, you need to create an admin API key using the bootstrap endpoint:

Bootstrap Admin Key
export ZIAGIT_API_ENDPOINT="https://git.ziacode.com"

tsx ~/Code/ZiaGit/ziagit-cli.ts bootstrap
⚠️ Important: The bootstrap endpoint can only be used once. Save your admin key immediately in a secure location. It will not be shown again.

2. Configure Environment Variables

Set up your environment to use ZiaGit:

Environment Setup
export ZIAGIT_API_KEY="zg_your_api_key_here"
export ZIAGIT_AUTHOR="Your Name"
export ZIAGIT_EMAIL="your@email.com"
export ZIAGIT_API_ENDPOINT="https://git.ziacode.com"

3. Make It Permanent (Optional)

Add these variables to your shell profile:

~/.zshrc or ~/.bashrc
echo 'export ZIAGIT_API_KEY="zg_your_key"' >> ~/.zshrc
echo 'export ZIAGIT_AUTHOR="Your Name"' >> ~/.zshrc
echo 'export ZIAGIT_EMAIL="your@email.com"' >> ~/.zshrc
echo 'export ZIAGIT_API_ENDPOINT="https://git.ziacode.com"' >> ~/.zshrc

source ~/.zshrc

Quick Start

Create Your First Repository

1

Initialize a Repository

tsx ~/Code/ZiaGit/ziagit-cli.ts init my-project
2

Navigate to Your Project

cd ~/Code/MyProjects/my-project
3

Make Some Changes

echo "# My Project" > README.md
mkdir src
echo "console.log('Hello ZiaGit');" > src/index.js
4

Commit Your Changes

tsx ~/Code/ZiaGit/ziagit-cli.ts commit my-project main

You'll be prompted to enter a commit message interactively.

5

View Commit History

tsx ~/Code/ZiaGit/ziagit-cli.ts log my-project main

Architecture

System Overview

ZiaGit uses a git-inspired architecture with content-addressable storage:

Client Layer

CLI Tool REST API Clients Slash Commands

API Layer

Cloudflare Workers Authentication REST Endpoints

Storage Layer

Cloudflare R2 Content-Addressable Storage SHA-256 Hashing

Git Objects

Blob

Stores file contents

type: "blob"

Tree

Directory structure with blob/tree references

type: "tree"

Commit

Snapshot with metadata and parent refs

type: "commit"

Storage Model

Directory Structure

repos/
├── {repo-name}/
│   ├── meta.json              # Repository metadata
│   ├── objects/
│   │   └── {sha256-hash}      # Git objects (blobs, trees, commits)
│   └── refs/
│       └── heads/
│           └── {branch-name}  # Branch pointers
└── auth/
    └── keys/
        └── {key-id}.json      # API keys (hashed)

Object Storage

All content is stored using SHA-256 content addressing:

  • Immutable: Objects never change once created
  • Deduplicated: Identical content stored once
  • Verifiable: Content integrity guaranteed by hash

Cost Estimates

Service Free Tier After Free Tier
R2 Storage 10 GB $0.015/GB/month
Class A Operations 1M requests $4.50/million
Class B Operations 10M requests $0.36/million
Egress Always Free
Workers Requests 100K/day $0.50/million

Security

API Key Security

  • Cryptographically Secure: 256-bit random keys using Web Crypto API
  • SHA-256 Hashing: Keys hashed before storage, never stored in plaintext
  • Bearer Token Auth: Industry-standard authentication method
  • One-Time Bootstrap: Initial admin key creation is protected

Permission Scopes

Read

  • View repositories
  • View commits
  • View branches
  • Download files

Write

  • All read permissions
  • Create commits
  • Create branches
  • Initialize repositories

Admin

  • All write permissions
  • Manage API keys
  • Revoke access
  • Full system control

Best Practices

  • Store API keys securely (use environment variables)
  • Never commit API keys to repositories
  • Use read-only keys for CI/CD systems
  • Rotate keys regularly
  • Revoke unused keys immediately

API Key Management

Create API Key

Create with specific permissions
tsx ~/Code/ZiaGit/ziagit-cli.ts key:create "My App" write

Permissions: read | write | admin

List API Keys

View all keys
tsx ~/Code/ZiaGit/ziagit-cli.ts key:list

Revoke API Key

Revoke by ID
tsx ~/Code/ZiaGit/ziagit-cli.ts key:revoke KEY_ID

Repository Commands

Initialize Repository

tsx ~/Code/ZiaGit/ziagit-cli.ts init <repo-name>

Creates a new repository with a default "main" branch.

List Repositories

tsx ~/Code/ZiaGit/ziagit-cli.ts repos

Commit Changes

tsx ~/Code/ZiaGit/ziagit-cli.ts commit <repo-name> <branch>

Commits all changes in the current directory. You'll be prompted for a commit message.

View Commit History

tsx ~/Code/ZiaGit/ziagit-cli.ts log <repo-name> <branch>

Show Commit Details

tsx ~/Code/ZiaGit/ziagit-cli.ts show <repo-name> <commit-hash>

View File Contents

tsx ~/Code/ZiaGit/ziagit-cli.ts cat <repo-name> <commit-hash> <file-path>

Branch Commands

List Branches

tsx ~/Code/ZiaGit/ziagit-cli.ts branches <repo-name>

Create Branch

tsx ~/Code/ZiaGit/ziagit-cli.ts branch <repo-name> <branch-name> <from-commit>

Creates a new branch from the specified commit hash.

Example: Create Feature Branch

# Get the latest commit hash from main
tsx ~/Code/ZiaGit/ziagit-cli.ts log my-project main

# Create new branch from that commit
tsx ~/Code/ZiaGit/ziagit-cli.ts branch my-project feature/new-ui abc123def456

Commit Operations

Creating a Commit

When you commit, ZiaGit:

  1. Scans all files in the current directory
  2. Creates blob objects for each file
  3. Builds a tree structure representing directories
  4. Creates a commit object with metadata
  5. Updates the branch reference

Commit Message Format

Use conventional commit format for better history:

feat: Add new user authentication
fix: Resolve memory leak in parser
docs: Update API documentation
refactor: Simplify database queries

What Gets Committed

ZiaGit automatically excludes common patterns:

  • node_modules/
  • .git/
  • dist/, build/
  • .DS_Store
  • Hidden files (.env, etc.)

REST API

Base URL: https://git.ziacode.com

Repository Endpoints

POST
/repos/{repo}/init

Initialize a new repository

GET
/repos

List all repositories

POST
/repos/{repo}/commits

Create a new commit

GET
/repos/{repo}/history/{branch}

Get commit history for a branch

GET
/repos/{repo}/commits/{hash}

Get commit details

Branch Endpoints

GET
/repos/{repo}/branches

List all branches

POST
/repos/{repo}/branches/{name}

Create a new branch

Example: Create Commit via API

cURL Example
curl -X POST https://git.ziacode.com/repos/my-project/commits \
  -H "Authorization: Bearer zg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "branch": "main",
    "message": "Initial commit",
    "author": {
      "name": "Your Name",
      "email": "your@email.com"
    },
    "files": {
      "README.md": "# My Project",
      "src/index.js": "console.log(\"Hello\");"
    }
  }'

Authentication

Bearer Token Authentication

All API requests (except bootstrap) require authentication via Bearer token:

HTTP Header
Authorization: Bearer zg_your_api_key_here

Example Requests

List Repositories
curl -H "Authorization: Bearer $ZIAGIT_API_KEY" \
  https://git.ziacode.com/repos
View Commit History
curl -H "Authorization: Bearer $ZIAGIT_API_KEY" \
  https://git.ziacode.com/repos/my-project/history/main
Get File Content
curl -H "Authorization: Bearer $ZIAGIT_API_KEY" \
  https://git.ziacode.com/repos/my-project/commits/abc123/files/src/index.js

Permissions

Permission Hierarchy

Admin

Full system access

▼ includes
Write

Create commits & branches

▼ includes
Read

View repositories & files

Permission Matrix

Operation Read Write Admin
List repositories
View commits
List branches
Download files
Initialize repository -
Create commits -
Create branches -
Create API keys - -
List API keys - -
Revoke API keys - -

Claude Slash Commands

All plugins scaffolded with the Local Add-on automatically include ZiaGit slash commands.

Available Commands

/git

Commit all changes to ZiaGit

# In Claude Code, type:
/git

# Claude will:
# 1. Show all files to be committed
# 2. Ask for commit message
# 3. Commit to ZiaGit
# 4. Show commit hash

/status

Show project and ZiaGit status

/status

/deploy

Deploy plugin to Local by Flywheel site

/deploy

/test

Run plugin tests

/test

/release

Prepare plugin for release

/release

WordPress Plugin Integration

CLAUDE.MD Configuration

Each WordPress plugin includes a CLAUDE.MD file with ZiaGit integration instructions.

Environment Setup for Plugins

export ZIAGIT_API_KEY="zg_your_key"
export ZIAGIT_AUTHOR="Your Name"
export ZIAGIT_EMAIL="your@email.com"

Plugin Repositories

Current plugins using ZiaGit:

  • electrical-intranet-pro - Branch: main
  • central-lms-manager - Branch: main
  • seo-content-optimizer - Branch: main
  • n1-intranet - Branch: main
  • home-cleaning-estimator - Branch: main
  • test-plugin - Branch: main

Automatic Scaffolding

New plugins created with the Local Add-on automatically include:

  • Pre-configured slash commands
  • ZiaGit documentation in CLAUDE.MD
  • Repository name matching plugin slug
  • Development workflow guides