::Sarah Chen::3 min read

Getting Started with CommitKey: Git Infrastructure for AI Agents

getting-started
api
git
ai-agents
Getting Started with CommitKey: Git Infrastructure for AI Agents
[L]earn how to set up and use CommitKey's API-first Git infrastructure for your AI agents and SaaS platforms.

CommitKey provides a modern, API-first approach to Git infrastructure that's perfect for AI agents and SaaS platforms. In this guide, we'll walk through setting up your first repository and making your first commit.

Why CommitKey?

Traditional Git hosting services weren't designed for programmatic access at scale. CommitKey bridges this gap by providing:

  • API-First Design: Every operation is available through our REST API
  • Organization Ownership: Your repositories stay under your control
  • AI Agent Optimized: Built specifically for automated workflows
  • Scalable Infrastructure: Handle thousands of repositories and commits

Setting Up Your First Repository

1. Create an Account

First, sign up for a CommitKey account at commitkey.dev. You'll get access to our API and dashboard.

2. Generate API Keys

Navigate to your account settings and generate a new API key. Keep this secure - you'll need it for all API calls.

curl -X POST https://api.commitkey.dev/v1/repositories \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-first-repo",
    "description": "My first CommitKey repository",
    "private": false
  }'

3. Initialize Your Repository

Once created, you can start making commits immediately:

# Clone the repository
git clone https://git.commitkey.dev/your-org/my-first-repo.git
cd my-first-repo

# Make your first commit
echo "# My First Repo" > README.md
git add README.md
git commit -m "Initial commit"
git push origin main

Working with AI Agents

CommitKey's API makes it easy to integrate with AI agents. Here's a simple example using Python:

import requests

class CommitKeyClient:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = "https://api.commitkey.dev/v1"
    
    def create_commit(self, repo_id, message, files):
        """Create a new commit with the specified files"""
        response = requests.post(
            f"{self.base_url}/repositories/{repo_id}/commits",
            headers={"Authorization": f"Bearer {self.api_key}"},
            json={
                "message": message,
                "files": files
            }
        )
        return response.json()

# Usage
client = CommitKeyClient("your-api-key")
client.create_commit(
    repo_id="repo-123",
    message="AI-generated code update",
    files={
        "src/main.py": "print('Hello from AI!')"
    }
)

Best Practices

Following these best practices will help you get the most out of CommitKey and maintain a healthy development workflow.

Repository Organization

  • Use descriptive repository names
  • Include comprehensive README files
  • Set up proper branch protection rules
  • Use semantic versioning for releases

API Usage

  • Always use HTTPS for API calls
  • Implement proper error handling
  • Use pagination for large result sets
  • Cache responses when appropriate

Security

  • Rotate API keys regularly
  • Use environment variables for sensitive data
  • Implement proper access controls
  • Monitor API usage

Next Steps

Now that you have your first repository set up, explore these advanced features:

Getting Help

If you run into any issues:

Happy coding with CommitKey!

Enjoyed this post?

Subscribe to our newsletter for more insights on Git infrastructure and AI agents.