Skip to content

Swiftzwif/claude-code-is-programmable

 
 

Repository files navigation

Claude Code is Programmable

This repository demonstrates how to use Claude Code programmatically, showcasing examples in different programming languages. Watch this video to understand why this is so important for next generation engineering.

Claude Code is Programmable

Quick Start

First off - run these right away to understand how important this is:

# Claude Code example (with only Write and Edit tools allowed)
claude -p "make a hello.js script that prints hello" --allowedTools "Write" "Edit"

# Aider equivalent example
aider --message "make a hello.js script that prints hello" hello.js

Here's the big trick - with Claude Code, you can call ANY TOOL IN ANY ORDER IN NATURAL LANGUAGE.

Check out the other examples in the repo to understand how to scale your impact with this feature.

Watch this video to internalize how important this is for next generation engineering. View the brief anthropic documentation here and a more comprehensive write up on agentic coding here. The Claude Code team is doing incredible work.

You can also use Aider as a programmable ai coding tool to do similar things although it's strictly limited to AI Coding (which is still incredibly useful). Check out the documentation here.

Setup

Configuration Files

  1. MCP (Multi-call Protocol) Configuration

    • Copy the sample configuration file to create your own:
      cp .mcp.sample.json .mcp.json
    • Edit .mcp.json to add your Notion API key in the OPENAPI_MCP_HEADERS section:
      {
        "mcpServers": {
          "notionApi": {
            "command": "npx",
            "args": ["-y", "@notionhq/notion-mcp-server"],
            "env": {
              "OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer YOUR_NOTION_API_KEY\", \"Notion-Version\": \"2022-06-28\" }"
            }
          }
        }
      }
  2. Environment Variables

    • Copy the sample environment file:
      cp .env.sample .env
    • Add the following API keys to your .env file:
      NOTION_INTERNAL_INTEGRATION_SECRET=your_notion_integration_secret
      ANTHROPIC_API_KEY=your_anthropic_api_key
      OPENAI_API_KEY=your_openai_api_key
      

File Descriptions

Shell Scripts

  • claude_code_is_programmable_1.sh: Simple shell script that uses Claude Code's CLI to generate a basic "hello.js" script with limited allowed tools.
    sh claude_code_is_programmable_1.sh
  • aider_is_programmable_1.sh: Similar script using Aider to create a "hello.js" file.
    sh aider_is_programmable_1.sh
  • reset.sh: Utility script to clean up branches and directories created by the demo scripts.
    sh reset.sh

Python Files

  • claude_code_is_programmable_2.py: Python script that executes Claude Code to create a TypeScript CLI todo app, with permissions for Edit, Replace, Bash, and Create tools.
    uv run claude_code_is_programmable_2.py
  • claude_code_is_programmable_3.py: Advanced Python script integrating Claude Code with Notion API for todo management, including rich console output and streaming results. Requires a Notion page name as an argument.
    uv run claude_code_is_programmable_3.py "My Notion Page"
  • aider_is_programmable_2.py: Python script that uses Aider to create a TypeScript todo application with git operations.
    uv run aider_is_programmable_2.py

JavaScript Files

  • claude_code_is_programmable_2.js: JavaScript version of the Claude Code script that creates a TypeScript todo app, with permissions for Edit, Replace, Bash, and Create tools.
    bun claude_code_is_programmable_2.js
  • aider_is_programmable_2.js: JavaScript version of the Aider script for creating a TypeScript todo app with git operations.
    bun aider_is_programmable_2.js

Bonus Directory

  • starter_notion_agent.py: A starter template for creating a Notion agent using the OpenAI Agent SDK.
    uv run bonus/starter_notion_agent.py
  • claude_code_inside_openai_agent_sdk_4_bonus.py: An advanced implementation that integrates Claude Code within the OpenAI Agent SDK. Requires a Notion page name as an argument.
    uv run bonus/claude_code_inside_openai_agent_sdk_4_bonus.py "My Notion Page"

Core Tools Available in Claude Code

  • Task: Launch an agent to perform complex tasks
  • Bash: Execute bash commands in a shell
  • Batch: Run multiple tools in parallel
  • Glob: Find files matching patterns
  • Grep: Search file contents with regex
  • LS: List directory contents
  • Read: Read file contents
  • Edit: Make targeted edits to files
  • Write: Create or overwrite files
  • NotebookRead/Edit: Work with Jupyter notebooks
  • WebFetch: Get content from websites

About

Scale your compute with Claude Code as a programmable agentic coding tool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 92.1%
  • JavaScript 7.2%
  • Shell 0.7%