### Install and Run PythonClaw Source: https://github.com/ericwang915/pythonclaw/blob/main/README.md Install PythonClaw using pip and run the initial setup wizard. This is the recommended way to get started. ```bash pip install pythonclaw pythonclaw onboard pythonclaw start pythonclaw chat pythonclaw stop ``` -------------------------------- ### PythonClaw Setup Wizard Example Source: https://github.com/ericwang915/pythonclaw/blob/main/README.md An example of the interactive setup wizard for PythonClaw, showing how to select an LLM provider and enter an API key. The wizard validates the key before completing the setup. ```bash $ pythonclaw start ╔══════════════════════════════════════╗ ║ PythonClaw — Setup Wizard ║ ╚══════════════════════════════════════╝ Choose your LLM provider: 1. DeepSeek 2. Grok (xAI) 3. Claude (Anthropic) 4. Gemini (Google) 5. Kimi (Moonshot) 6. GLM (Zhipu / ChatGLM) Enter number (1-6): 2 → Grok (xAI) API Key: ******** → Key set (xai-****) Validating... ✔ Valid! ✔ Setup complete! [PythonClaw] Daemon started (PID 12345). [PythonClaw] Dashboard: http://localhost:7788 ``` -------------------------------- ### Setup Development Environment Source: https://github.com/ericwang915/pythonclaw/blob/main/CONTRIBUTING.md Clone the repository, create and activate a virtual environment, install the project in editable mode, and run the test suite. ```bash git clone https://github.com/ericwang915/PythonClaw.git cd PythonClaw python -m venv .venv && source .venv/bin/activate pip install -e . pytest tests/ -v ``` -------------------------------- ### Install Skill from Marketplace Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/web/static/index.html Handles the process of installing a skill from the marketplace. Prompts the user for confirmation, updates the UI to show installation status, and makes a POST request to the API. Displays success or error messages. ```javascript async function marketplaceInstall(skillId) { if (!confirm(`Install skill "${skillId}" from ClawHub?`)) return; const status = document.getElementById('sh-status'); status.textContent = `Installing ${skillId}…`; status.classList.remove('hidden'); const btn = document.querySelector(`button[onclick="marketplaceInstall('${skillId}')"]`); if (btn) { btn.disabled = true; btn.textContent = 'Installing…'; btn.classList.add('opacity-50'); } try { const res = await fetch('/api/marketplace/install', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ skill_id: skillId }), }); const data = await res.json(); if (data.ok) { const name = data.skill_name || skillId; status.innerHTML = `✓ Installed & ready! Use in chat: use_skill("${_esc(name)}")` + (data.skill_count ? ` (${data.skill_count} skills total)` : ''); if (btn) { btn.textContent = '✓ Installed'; btn.classList.replace('bg-brand-500/20', 'bg-green-500/20'); btn.classList.replace('text-brand-400', 'text-green-400'); } } else { status.innerHTML = `✗ Error: ${_esc(data.error || 'Unknown error')}`; if (btn) { btn.disabled = false; btn.textContent = 'Install'; btn.classList.remove('opacity-50'); } } } catch (e) { status.innerHTML = `✗ Failed: ${_esc(e.message)}`; if (btn) { btn.disabled = false; btn.textContent = 'Install'; btn.classList.remove('opacity-50'); } } } ``` -------------------------------- ### Example: Show Bitcoin Price Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/finance/SKILL.md Example command to fetch the current price of Bitcoin (BTC-USD). ```bash python {skill_path}/fetch_quote.py BTC-USD ``` -------------------------------- ### Search and Install Skills with SkillHub Source: https://context7.com/ericwang915/pythonclaw/llms.txt Use SkillHub to search for available skills and install them. Specify a directory for skill installation. ```python from pythonclaw.core.skillhub import SkillHub hub = SkillHub() results = hub.search("image resize") for skill in results[:3]: print(f"{skill['id']}: {skill['description']}") hub.install("img_resizer", skills_dir="~/.pythonclaw/context/skills") ``` -------------------------------- ### Example: Get EUR/USD Exchange Rate Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/finance/SKILL.md Example command to retrieve the current exchange rate for Euro to US Dollar (EURUSD=X). ```bash python {skill_path}/fetch_quote.py EURUSD=X ``` -------------------------------- ### Example: Create PDF from Images Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_convert/SKILL.md This example shows how to create a PDF document named 'album.pdf' from a list of image files. ```bash python {skill_path}/convert_pdf.py to-pdf album.pdf img1.png img2.jpg ``` -------------------------------- ### Install gog CLI Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/google/workspace/SKILL.md Install the gog CLI using Homebrew. This is the first step for using the Google Workspace integration. ```bash brew install steipete/tap/gogcli ``` -------------------------------- ### Install and Run PythonClaw CLI Commands Source: https://context7.com/ericwang915/pythonclaw/llms.txt Install the PythonClaw package and use its CLI for onboarding, starting/stopping the daemon, and interactive chat. The daemon can be started with support for various messaging channels. ```bash pip install pythonclaw # Interactive first-time setup pythonclaw onboard # Start the daemon (web dashboard at http://localhost:7788) pythonclaw start # Start with messaging channels pythonclaw start --channels telegram discord whatsapp # Interactive CLI chat pythonclaw chat # Stop the daemon pythonclaw stop # Check daemon status pythonclaw status ``` -------------------------------- ### Example: Weather in Tokyo Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/weather/SKILL.md Demonstrates how to get the weather in Tokyo using either the Python script or the curl command with wttr.in. ```bash python {skill_path}/weather.py "Tokyo" ``` ```bash curl -s wttr.in/Tokyo ``` -------------------------------- ### Example: Compare AAPL and MSFT Stock Prices Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/finance/SKILL.md Example command to compare the stock prices of Apple (AAPL) and Microsoft (MSFT). ```bash python {skill_path}/fetch_quote.py AAPL MSFT ``` -------------------------------- ### Install spotify-player CLI Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/media/spotify/SKILL.md Install the spotify-player command-line tool using Homebrew on macOS. This provides an alternative way to control Spotify. ```bash brew install spotify_player # macOS ``` -------------------------------- ### Install YouTube Skill Dependencies Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/youtube/SKILL.md Install the necessary Python packages for the YouTube skill: yt-dlp and youtube-transcript-api. ```bash pip install yt-dlp youtube-transcript-api ``` -------------------------------- ### Install PythonClaw from Source Source: https://github.com/ericwang915/pythonclaw/blob/main/README.md Clone the repository and install PythonClaw in editable mode. This is useful for development or if you need the latest changes. ```bash git clone https://github.com/ericwang915/PythonClaw.git cd PythonClaw pip install -e . pythonclaw onboard ``` -------------------------------- ### Example: Weather in Paris in Fahrenheit Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/weather/SKILL.md Illustrates how to get the weather for Paris in Fahrenheit using the Python script with the --units imperial option. ```bash python {skill_path}/weather.py "Paris" --units imperial ``` -------------------------------- ### Example: Protect PDF with Password Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_protect/SKILL.md Demonstrates how to protect a PDF file with a specified password. ```bash python {skill_path}/protect_pdf.py encrypt doc.pdf protected.pdf --password mypass ``` -------------------------------- ### File Input Example Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/code_runner/SKILL.md Execute Python code stored in a file using the `--file` option. ```bash python {skill_path}/run_code.py --file script.py ``` -------------------------------- ### Install Skills from Skill Marketplace (CLI) Source: https://context7.com/ericwang915/pythonclaw/llms.txt Manage skills from the Skill Marketplace using the `pythonclaw skill` CLI commands. This includes searching, browsing, viewing info, and installing skills. ```bash # Search skills by keyword pythonclaw skill search "database backup" # Results: # [pg_backup] PostgreSQL database backup and restore utility # [mysql_export] Export MySQL tables to CSV or SQL dump # ... # Browse top-rated skills pythonclaw skill browse # View skill details pythonclaw skill info pg_backup # Install a skill pythonclaw skill install pg_backup # Installing pg_backup... # ✔ Skill installed to ~/.pythonclaw/context/skills/dev/pg_backup/ ``` -------------------------------- ### Example: Fetch Tesla Stock Price Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/finance/SKILL.md Example command to retrieve the current stock price for Tesla (TSLA). ```bash python {skill_path}/fetch_quote.py TSLA ``` -------------------------------- ### Skill Metadata and Instructions Example Source: https://github.com/ericwang915/pythonclaw/blob/main/README.md This YAML example shows how to define a skill's metadata (name, description) and its instructions for execution. The 'code_runner' skill executes Python code in a subprocess. ```yaml --- name: code_runner description: Execute Python code safely in an isolated subprocess. --- # Code Runner ## Instructions Run `python {skill_path}/run_code.py "expression"` ``` -------------------------------- ### Install Dependencies Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_convert/SKILL.md Before using the PDF Convert skill, ensure you have installed the necessary Python libraries: PyPDF2 for PDF manipulation and Pillow for image processing. ```bash pip install PyPDF2 Pillow ``` -------------------------------- ### Example: Convert PDF to PNGs Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_convert/SKILL.md This example demonstrates how to convert all pages of a PDF document into PNG images and save them in a specified output directory. ```bash python {skill_path}/convert_pdf.py to-images doc.pdf --output ./images/ ``` -------------------------------- ### Install Dependencies Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/csv_analyzer/SKILL.md Install the necessary Python libraries for the CSV Analyzer skill. 'pandas' is required for data manipulation, and 'openpyxl' is needed for reading Excel files. ```bash pip install pandas openpyxl ``` -------------------------------- ### Install PyPDF2 Dependency Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_reader/SKILL.md Install the required PyPDF2 library using pip before using the PDF reader skill. ```bash pip install PyPDF2 ``` -------------------------------- ### PythonClaw Configuration Example Source: https://github.com/ericwang915/pythonclaw/blob/main/README.md This JSON configuration file defines settings for LLM providers, API keys, web server, channels, and concurrency. Environment variables can override these settings. ```jsonc { "llm": { "provider": "grok", "grok": { "apiKey": "xai-...", "model": "grok-3" } }, "tavily": { "apiKey": "" }, "deepgram": { "apiKey": "" }, "web": { "host": "0.0.0.0", "port": 7788 }, "channels": { "telegram": { "token": "" }, "discord": { "token": "" }, "whatsapp": { "phoneNumberId": "", "token": "", "verifyToken": "pythonclaw_verify" } }, "isolation": { "perGroup": false }, "concurrency": { "maxAgents": 4 } } ``` -------------------------------- ### Stdin Input Example Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/code_runner/SKILL.md Pipe Python code to the script via standard input. ```bash echo "print('Hello from stdin')" | python {skill_path}/run_code.py ``` -------------------------------- ### Example: 5-Day Forecast for New York Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/weather/SKILL.md Shows how to request a 5-day weather forecast for New York using the Python script with the --forecast option. ```bash python {skill_path}/weather.py "New York" --forecast 5 ``` -------------------------------- ### Example: Unlock PDF Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_protect/SKILL.md Illustrates the command to decrypt a password-protected PDF file. ```bash python {skill_path}/protect_pdf.py decrypt locked.pdf unlocked.pdf --password pass123 ``` -------------------------------- ### Example: Convert Specific PDF Page to JPEG Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_convert/SKILL.md This example demonstrates converting only the third page of a PDF document into a JPEG image. ```bash python {skill_path}/convert_pdf.py to-images doc.pdf --pages 3 --img-format jpeg ``` -------------------------------- ### JSON Output Format Example Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/code_runner/SKILL.md Configure the output to be in JSON format, including stdout, stderr, and exit code, using the `--format json` option. ```bash python {skill_path}/run_code.py --format json --code "print(10/2)" ``` -------------------------------- ### Inline Code Input Example Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/code_runner/SKILL.md Provide Python code directly as an argument to the `--code` option. ```bash python {skill_path}/run_code.py --code "print(2+2)" ``` -------------------------------- ### Run YouTube Skill Commands Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/youtube/SKILL.md Execute the youtube_info.py script with different commands and options to retrieve video information, transcripts, or search YouTube. Ensure dependencies are installed. ```bash python {skill_path}/youtube_info.py URL [command] [options] ``` -------------------------------- ### Example: Restrict Printing Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_protect/SKILL.md Shows how to encrypt a PDF file while disabling the printing option. ```bash python {skill_path}/protect_pdf.py encrypt doc.pdf out.pdf --password pass --no-print ``` -------------------------------- ### Authentication Header Example Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/http_request/SKILL.md Use the `--header` option to include authentication tokens for APIs that require authorization. Ensure proper escaping for shell commands. ```bash --header "Authorization: Bearer " ``` -------------------------------- ### Start PythonClaw Daemon with Specific Channels Source: https://github.com/ericwang915/pythonclaw/blob/main/README.md Start the PythonClaw agent as a background daemon, specifying which messaging channels to enable. The default web dashboard will be available at http://localhost:7788. ```bash pythonclaw start --channels telegram discord whatsapp ``` -------------------------------- ### Developer Preferences Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/tools/TOOLS.md List preferred coding styles, default languages, and timezones to guide agent behavior. ```markdown ### Preferences - Code style: use type hints, prefer pathlib over os.path - Default language: English - Timezone: Asia/Shanghai ``` -------------------------------- ### PythonClaw CLI Skill Management Source: https://github.com/ericwang915/pythonclaw/blob/main/README.md Use these bash commands to search for and install skills from the ClawHub marketplace using the PythonClaw CLI. ```bash pythonclaw skill search "database backup" pythonclaw skill install ``` -------------------------------- ### Timeout Option Example Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/code_runner/SKILL.md Set a maximum execution time in seconds for the Python code using the `--timeout` option. ```bash python {skill_path}/run_code.py --timeout 60 --code "import time; time.sleep(5)" ``` -------------------------------- ### PythonClaw Configuration (`pythonclaw.json`) Source: https://context7.com/ericwang915/pythonclaw/llms.txt Example `pythonclaw.json` file structure for configuring LLM providers, API keys, web server settings, messaging channels, and agent isolation. Environment variables can override these settings. ```json { "llm": { "provider": "grok", "grok": { "apiKey": "xai-...", "model": "grok-3" }, "deepseek": { "apiKey": "sk-...", "model": "deepseek-chat" }, "claude": { "apiKey": "sk-ant-...", "model": "claude-sonnet-4-20250514" }, "gemini": { "apiKey": "...", "model": "gemini-2.0-flash" }, "kimi": { "apiKey": "...", "model": "moonshot-v1-128k" }, "glm": { "apiKey": "...", "model": "glm-4-flash" } }, "tavily": { "apiKey": "" }, // optional web search "deepgram": { "apiKey": "" }, // optional voice input "web": { "host": "0.0.0.0", "port": 7788 }, "channels": { "telegram": { "token": "" }, "discord": { "token": "" }, "whatsapp": { "phoneNumberId": "", "token": "", "verifyToken": "pythonclaw_verify" } }, "isolation": { "perGroup": false }, // true = each chat session gets its own memory "concurrency": { "maxAgents": 4 } } ``` -------------------------------- ### No Capture Output Example Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/code_runner/SKILL.md Stream the output directly without capturing it by using the `--no-capture` option. ```bash python {skill_path}/run_code.py --no-capture --code "print('Streaming output')" ``` -------------------------------- ### Get YouTube Video Info Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/youtube/SKILL.md Retrieve video title, duration, views, and description by running the script with the 'info' command. This is the default command if none is specified. ```bash python {skill_path}/youtube_info.py info ``` -------------------------------- ### Get Current Playback Info Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/media/spotify/SKILL.md Retrieve information about the currently playing track using the spotify_ctl.py script. ```bash python {skill_path}/spotify_ctl.py now-playing ``` -------------------------------- ### Get Current Weather with curl and wttr.in Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/weather/SKILL.md Fetch current weather details for a city using curl and wttr.in. The format parameter allows customization of the output, including specific data points like temperature and wind. ```bash curl -s "wttr.in/CityName?format=%l%20%t%20%h%20%w%20%c" ``` -------------------------------- ### Initialize and Use Agent Source: https://context7.com/ericwang915/pythonclaw/llms.txt Demonstrates basic Agent initialization with an OpenAI-compatible provider and simple chat interactions, including multimodal input and streaming responses. Ensure the provider is correctly configured with API keys and base URLs. ```python from pythonclaw import Agent from pythonclaw.core.llm.openai_compatible import OpenAICompatibleProvider # --- Basic usage with any OpenAI-compatible API --- provider = OpenAICompatibleProvider( api_key="sk-ாலத்தில்", base_url="https://api.deepseek.com/v1", model_name="deepseek-chat", ) agent = Agent(provider=provider) # Simple chat response = agent.chat("What is the capital of France?") print(response) # "The capital of France is Paris." # Multimodal input (image + text) — only for providers with supports_images=True response = agent.chat([ {"type": "text", "text": "What is in this image?"}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgo..."}}, ]) # Streaming responses def on_token(token: str): print(token, end="", flush=True) full_response = agent.chat_stream("Explain quantum entanglement", on_token=on_token) print() # newline after stream ``` -------------------------------- ### Get File Info Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/csv_analyzer/SKILL.md Use the 'info' command to view column types, shape, and missing values of a CSV or Excel file. This is the default command if none is specified. ```bash python {skill_path}/analyze.py data.csv info ``` -------------------------------- ### Get Repository Details via Python Fallback Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/github/SKILL.md Use the Python fallback script to retrieve details for a specific repository. This command is executed via `python {skill_path}/gh.py`. ```bash python {skill_path}/gh.py repo ``` -------------------------------- ### Configure OpenAICompatibleProvider for Various APIs Source: https://context7.com/ericwang915/pythonclaw/llms.txt Illustrates how to initialize `OpenAICompatibleProvider` for different services like DeepSeek, Grok (xAI), and Kimi (Moonshot) by specifying the appropriate API key, base URL, and model name. Direct chat calls and streaming are also shown. ```python from pythonclaw.core.llm.openai_compatible import OpenAICompatibleProvider # DeepSeek provider = OpenAICompatibleProvider( api_key="sk-ாலத்தில்", base_url="https://api.deepseek.com/v1", model_name="deepseek-chat", ) # Grok (xAI) provider = OpenAICompatibleProvider( api_key="xai-ாலத்தில்", base_url="https://api.x.ai/v1", model_name="grok-3", ) # Kimi (Moonshot) provider = OpenAICompatibleProvider( api_key="sk-ாலத்தில்", base_url="https://api.moonshot.cn/v1", model_name="moonshot-v1-128k", ) # Direct chat call (returns OpenAI-compatible response object) response = provider.chat( messages=[{"role": "user", "content": "Hello!"}], tools=None, tool_choice="none", ) print(response.choices[0].message.content) # "Hello! How can I help you?" # Streaming gen = provider.chat_stream( messages=[{"role": "user", "content": "Tell me a joke"}], ) try: while True: chunk = next(gen) if chunk.get("type") == "text_delta": print(chunk["text"], end="", flush=True) except StopIteration as si: final_response = si.value # MockResponse with full assembled content ``` -------------------------------- ### Initialize and Use PythonClaw Agent Source: https://github.com/ericwang915/pythonclaw/blob/main/README.md Demonstrates how to initialize an agent with an OpenAI-compatible provider and use it to chat. Ensure you have the necessary API key and base URL. ```python from pythonclaw import Agent from pythonclaw.core.llm.openai_compatible import OpenAICompatibleProvider provider = OpenAICompatibleProvider( api_key="sk-...", base_url="https://api.deepseek.com/v1", model_name="deepseek-chat", ) agent = Agent(provider=provider) print(agent.chat("What is the capital of France?")) ``` -------------------------------- ### Get Current Local Time Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/system/time/SKILL.md Execute this command to get the current time in the local timezone. Ensure the `time_util.py` script is accessible. ```bash python {skill_path}/time_util.py ``` -------------------------------- ### Initialize and Use AnthropicProvider Source: https://context7.com/ericwang915/pythonclaw/llms.txt Demonstrates initializing the `AnthropicProvider` for Claude models, including setting the API key and model name. It shows how to perform synchronous chat requests and notes that multimodal input is supported. ```python from pythonclaw.core.llm.anthropic_client import AnthropicProvider provider = AnthropicProvider( api_key="sk-ant-ாலத்தில்", # or a claude setup-token model_name="claude-sonnet-4-20250514", ) # supports_images = True — multimodal input supported # Synchronous chat response = provider.chat( messages=[{"role": "user", "content": "Summarize quantum computing in 2 sentences."} ], ) print(response.choices[0].message.content) ``` -------------------------------- ### Project Path Configuration Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/tools/TOOLS.md Specify project directories, their associated technologies, and deployment details for easy reference. ```markdown ### Projects - main repo → ~/code/myproject (Python 3.12, uses poetry) - docs site → ~/code/docs (Next.js, deployed on Vercel) ``` -------------------------------- ### Loading Configuration Source: https://context7.com/ericwang915/pythonclaw/llms.txt Demonstrates how to load the PythonClaw configuration, either the default or from a specified path, and how to force a reload. ```APIDOC ## Loading Configuration ### Description Loads the PythonClaw configuration. This function is automatically called on first access and is safe to call repeatedly. You can also specify an explicit path to the configuration file or force a reload. ### Usage ```python from pythonclaw import config # Load default configuration cfg = config.load() # Load configuration from a specific path cfg = config.load("/path/to/pythonclaw.json") # Force a reload of the configuration cfg = config.load(force=True) ``` ``` -------------------------------- ### Create Custom Skills at Runtime Source: https://context7.com/ericwang915/pythonclaw/llms.txt Create custom skills dynamically using the `create_skill` tool. This involves defining metadata, instructions, resources, and dependencies. The output confirms skill creation and registry refresh. ```python from pythonclaw.core.tools import create_skill result = create_skill( name="stock_fetcher", description="Fetch real-time stock prices. Use when the user asks about stock quotes.", instructions="""## Instructions Run `python {skill_path}/fetch.py "TICKER"` to fetch stock data. Output: current price, daily change, market cap. """, category="data", resources={ "fetch.py": "import yfinance as yf, sys t = yf.Ticker(sys.argv[1]) info = t.fast_info print(f\"Price: ${info.last_price:.2f} Change: {info.regular_market_change_percent:.2f}%\")" }, dependencies=["yfinance"], ) print(result) # "Skill 'stock_fetcher' created at /home/user/.pythonclaw/context/skills/data/stock_fetcher/ # Files: SKILL.md, fetch.py # Dependencies: # ✓ yfinance # Registry will be refreshed — the skill is now available via use_skill()." ``` -------------------------------- ### List Session Files by Date and Size Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/system/session_logs/SKILL.md Lists all session Markdown files in the default directory, sorted by size in a human-readable format. ```bash ls -lhS ~/.pythonclaw/context/sessions/*.md ``` -------------------------------- ### Get PDF Summary Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_reader/SKILL.md Obtain a summary of the PDF, including page and character counts, by using the --summary option. ```bash python {skill_path}/read_pdf.py file.pdf --summary ``` -------------------------------- ### GeminiProvider Initialization and Chat Source: https://context7.com/ericwang915/pythonclaw/llms.txt Initialize the GeminiProvider with an API key and model name, then use it to send a simple chat query. Supports multimodal input. ```python from pythonclaw.core.llm.gemini_client import GeminiProvider provider = GeminiProvider( api_key="AIza...", model_name="gemini-2.0-flash", ) # supports_images = True response = provider.chat( messages=[{"role": "user", "content": "What is 7 * 8?"}], ) print(response.choices[0].message.content) # "7 * 8 = 56" ``` -------------------------------- ### JSON Data Example Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/http_request/SKILL.md When sending JSON data in the request body, ensure it is valid JSON and properly escaped for shell execution. ```bash --data '{"key": "value"}' ``` -------------------------------- ### Get Unix Timestamp Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/system/time/SKILL.md This command retrieves the current Unix timestamp. The output is a numerical representation of the time since the Unix epoch. ```bash python {skill_path}/time_util.py --unix ``` -------------------------------- ### Configure Email Credentials Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/system/change_setting/SKILL.md Sets up email sender credentials, including the email address and password (or app-specific password). Ensure these are entered correctly for email functionalities. ```bash # Set email credentials python {skill_path}/update_config.py --set "skills.email.senderEmail" "me@gmail.com" python {skill_path}/update_config.py --set "skills.email.senderPassword" "app-password" ``` -------------------------------- ### Get Google Sheets Metadata Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/google/workspace/SKILL.md Retrieve metadata for a Google Sheet. The --json flag provides the output in a structured format. ```bash gog sheets metadata --json ``` -------------------------------- ### Agent Class - Basic Usage Source: https://context7.com/ericwang915/pythonclaw/llms.txt Demonstrates the basic usage of the Agent class for simple chat, multimodal input, and streaming responses. ```APIDOC ## Agent Class - Basic Usage ### Description This section shows how to initialize and use the `Agent` class for basic chat functionalities, including handling multimodal inputs and streaming responses. ### Initialization ```python from pythonclaw import Agent from pythonclaw.core.llm.openai_compatible import OpenAICompatibleProvider provider = OpenAICompatibleProvider( api_key="sk-ாலத்தில்", base_url="https://api.deepseek.com/v1", model_name="deepseek-chat", ) agent = Agent(provider=provider) ``` ### Simple Chat ```python response = agent.chat("What is the capital of France?") print(response) ``` ### Multimodal Input ```python response = agent.chat([ {"type": "text", "text": "What is in this image?"}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgo..."}}, ]) ``` ### Streaming Responses ```python def on_token(token: str): print(token, end="", flush=True) full_response = agent.chat_stream("Explain quantum entanglement", on_token=on_token) print() # newline after stream ``` ``` -------------------------------- ### Generate Random Integer Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/system/random/SKILL.md Use to generate a random integer within a specified range. The range is inclusive of both the start and end values. ```bash python {skill_path}/random_util.py --int 1 100 ``` -------------------------------- ### Get Time in Specific Timezone Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/system/time/SKILL.md Use this command to retrieve the current time for a specified timezone. Timezones must follow the IANA format. ```bash python {skill_path}/time_util.py --tz "America/New_York" ``` -------------------------------- ### OpenAICompatibleProvider - Usage Source: https://context7.com/ericwang915/pythonclaw/llms.txt Shows how to use the OpenAICompatibleProvider with various OpenAI-compatible APIs like DeepSeek, Grok, and Kimi for chat and streaming. ```APIDOC ## OpenAICompatibleProvider ### Description The `OpenAICompatibleProvider` class acts as a wrapper for any API that adheres to the OpenAI chat-completions contract. It supports streaming and tool calls. ### Initialization Examples #### DeepSeek ```python from pythonclaw.core.llm.openai_compatible import OpenAICompatibleProvider provider = OpenAICompatibleProvider( api_key="sk-ாலத்தில்", base_url="https://api.deepseek.com/v1", model_name="deepseek-chat", ) ``` #### Grok (xAI) ```python provider = OpenAICompatibleProvider( api_key="xai-ாலத்தில்", base_url="https://api.x.ai/v1", model_name="grok-3", ) ``` #### Kimi (Moonshot) ```python provider = OpenAICompatibleProvider( api_key="sk-ாலத்தில்", base_url="https://api.moonshot.cn/v1", model_name="moonshot-v1-128k", ) ``` ### Direct Chat Call ```python response = provider.chat( messages=[{"role": "user", "content": "Hello!"}], tools=None, tool_choice="none", ) print(response.choices[0].message.content) ``` ### Streaming ```python gen = provider.chat_stream( messages=[{"role": "user", "content": "Tell me a joke"}], ) try: while True: chunk = next(gen) if chunk.get("type") == "text_delta": print(chunk["text"], end="", flush=True) except StopIteration as si: final_response = si.value ``` ``` -------------------------------- ### Get a Specific Notion Page Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/productivity/notion/SKILL.md Retrieve a specific Notion page using its unique page ID. Ensure you have the correct page ID. ```bash python {skill_path}/notion_api.py get-page ``` -------------------------------- ### Create Calendar Event Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/google/workspace/SKILL.md Create a new calendar event with a title, start time, and end time. Always confirm before creating events. ```bash gog calendar create --title "Meeting" --start "2026-02-24T10:00" --end "2026-02-24T11:00" ``` -------------------------------- ### Configure Spotify API Credentials Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/media/spotify/SKILL.md Add your Spotify Client ID and Client Secret to the pythonclaw.json configuration file to enable the Spotify skill. ```json { "skills": { "spotify": { "clientId": "your-client-id", "clientSecret": "your-client-secret" } } } ``` -------------------------------- ### List User's Public Repositories via Python Fallback Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/dev/github/SKILL.md Use the Python fallback script to list a user's public repositories. This command is executed via `python {skill_path}/gh.py`. ```bash python {skill_path}/gh.py repos ``` -------------------------------- ### Streaming Chat Response Source: https://context7.com/ericwang915/pythonclaw/llms.txt Initiate a streaming chat session and process text deltas as they arrive. Handle the StopIteration exception to get the final result. ```python gen = provider.chat_stream( messages=[{"role": "user", "content": "Write a haiku about Python"}], ) try: while True: chunk = next(gen) if chunk["type"] == "text_delta": print(chunk["text"], end="", flush=True) except StopIteration as si: result = si.value ``` -------------------------------- ### Get Google Sheets Data Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/google/workspace/SKILL.md Retrieve data from a specified range within a Google Sheet. Use the --json flag for structured output. ```bash gog sheets get "Sheet1!A1:D10" --json ``` -------------------------------- ### Show Current Configuration Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/system/change_setting/SKILL.md Displays the current settings stored in the `pythonclaw.json` file. Use this to verify existing configurations before making changes. ```bash python {skill_path}/update_config.py --show ``` -------------------------------- ### Control spotify-player CLI Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/media/spotify/SKILL.md Use the spotify-player CLI to control playback, search for music, and manage playback state. ```bash spotify_player playback play ``` ```bash spotify_player playback pause ``` ```bash spotify_player search "query" ``` -------------------------------- ### Get Notion Page Content (Blocks) Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/productivity/notion/SKILL.md Fetch the content of a Notion page, returned as a list of blocks. This is useful for extracting structured data from a page. ```bash python {skill_path}/notion_api.py get-blocks ``` -------------------------------- ### Get 3-Day Forecast with curl and wttr.in Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/weather/SKILL.md Request a 3-day weather forecast for a specified city by appending '?2' to the wttr.in URL when using curl. ```bash curl -s "wttr.in/CityName?2" ``` -------------------------------- ### Inspect and Reset Configuration Source: https://context7.com/ericwang915/pythonclaw/llms.txt Details how to inspect the currently loaded configuration path and data, and how to reset the configuration cache. ```APIDOC ## Inspect and Reset Configuration ### Description Allows inspection of the configuration file path and the full configuration data as a dictionary. Also provides a method to reset the configuration cache, primarily for testing purposes. ### Usage ```python from pythonclaw import config # Get the path to the loaded configuration file path = config.config_path() # → Path or None # Get a copy of the full loaded configuration as a dictionary full = config.as_dict() # → full dict copy # Clear the configuration cache (useful for testing) config.reset() ``` ``` -------------------------------- ### Get JSON Weather Output with curl and wttr.in Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/weather/SKILL.md Obtain weather data in JSON format by appending '?format=j1' to the wttr.in URL when using curl. ```bash curl -s "wttr.in/CityName?format=j1" ``` -------------------------------- ### Display First N Rows Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/csv_analyzer/SKILL.md Use the 'head' command to display the first N rows of a file. Specify the number of rows with the --rows option; defaults to 10. ```bash python {skill_path}/analyze.py sales.xlsx head --rows 20 ``` -------------------------------- ### Get Human-Readable Weather with curl and wttr.in Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/weather/SKILL.md Retrieve weather information in a human-readable format by using curl with wttr.in without any specific format parameters. ```bash curl -s "wttr.in/CityName" ``` -------------------------------- ### Get Slack Member Info Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/communication/slack/SKILL.md Fetch information about a specific Slack user by their user ID. The bot must have permissions to read user data. ```bash python {skill_path}/slack_api.py user --user-id "U123" ``` -------------------------------- ### Initialize Web Dashboard Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/web/static/index.html Initializes the web dashboard by switching to the dashboard tab, connecting to the WebSocket, and refreshing the dashboard content. ```javascript switchTab('dashboard'); connectWebSocket(); refreshDashboard(); ``` -------------------------------- ### Configure Trello API Key and Token Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/productivity/trello/SKILL.md Set up your Trello API key and token in the pythonclaw.json configuration file to authenticate with the Trello API. ```json { "skills": { "trello": { "apiKey": "your-api-key", "token": "your-token" } } } ``` -------------------------------- ### Initialize and Use HybridRetriever Source: https://context7.com/ericwang915/pythonclaw/llms.txt Load a corpus from a directory and initialize a HybridRetriever for retrieval. This is useful for custom knowledge bases. ```python from pythonclaw.core.retrieval.retriever import HybridRetriever from pythonclaw.core.retrieval.chunker import load_corpus_from_directory corpus = load_corpus_from_directory("context/knowledge") retriever = HybridRetriever(provider=provider, use_sparse=True, use_dense=True, use_reranker=True) retriever.fit(corpus) hits = retriever.retrieve("deployment instructions", top_k=3) ``` -------------------------------- ### Create PDF from Text Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/pdf_writer/SKILL.md Generates a PDF document from plain text content. Use the --text option to provide the content directly. ```bash python {skill_path}/write_pdf.py output.pdf --text "Hello World" ``` -------------------------------- ### Basic Text-to-Speech with gTTS Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/media/tts/SKILL.md Use this command for basic text-to-speech conversion with gTTS. Ensure the output file path is correctly specified. ```bash python {skill_path}/speak.py "Hello, this is PythonClaw speaking." --output hello.mp3 ``` -------------------------------- ### Toggle Microphone for Voice Input Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/web/static/index.html Manages microphone access and recording for voice input using the Deepgram API. Handles starting, stopping, and transcribing audio. ```javascript let _micActive = false; function toggleMic() { if (_micActive) { stopMic(); return; } navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => { _micActive = true; const btn = document.getElementById('mic-btn'); btn.classList.add('!bg-red-600', '!text-white'); btn.title = 'Recording… click to stop'; _audioChunks = []; _mediaRecorder = new MediaRecorder(stream, { mimeType: 'audio/webm;codecs=opus' }); _mediaRecorder.ondataavailable = e => { if (e.data.size > 0) _audioChunks.push(e.data); }; _mediaRecorder.onstop = () => { stream.getTracks().forEach(t => t.stop()); const blob = new Blob(_audioChunks, { type: 'audio/webm' }); transcribeAudio(blob); }; _mediaRecorder.start(); }).catch(err => { console.error('Mic access denied:', err); alert('Microphone access denied. Please allow microphone access and try again.'); }); } ``` ```javascript function stopMic() { _micActive = false; const btn = document.getElementById('mic-btn'); btn.classList.remove('!bg-red-600', '!text-white'); btn.title = 'Voice input'; if (_mediaRecorder && _mediaRecorder.state !== 'inactive') { _mediaRecorder.stop(); } } ``` ```javascript async function transcribeAudio(blob) { const btn = document.getElementById('mic-btn'); btn.classList.add('animate-pulse'); btn.title = 'Transcribing…'; try { const resp = await fetch('/api/transcribe', { method: 'POST', headers: { 'Content-Type': 'audio/webm' }, body: blob, }); const data = await resp.json(); if (data.ok && data.transcript) { const input = document.getElementById('chat-input'); input.value = (input.value ? input.value + ' ' : '') + data.transcript; input.focus(); } else { alert(data.error || 'Transcription returned empty result.'); } } catch (e) { console.error('Transcribe error:', e); alert('Transcription failed: ' + e.message); } finally { btn.classList.remove('animate-pulse'); btn.title = 'Voice input'; } } ``` -------------------------------- ### Create a Trello Card Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/productivity/trello/SKILL.md Create a new Trello card with a specified title and description in a given list. Requires the target list ID. ```bash python {skill_path}/trello_api.py create-card --list --name "Card Title" --desc "Description" ``` -------------------------------- ### Generate Random Float Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/system/random/SKILL.md Use to generate a random floating-point number within a specified range. The range is inclusive of the start value and exclusive of the end value. ```bash python {skill_path}/random_util.py --float 0.0 1.0 ``` -------------------------------- ### KnowledgeRAG Initialization and Retrieval Source: https://context7.com/ericwang915/pythonclaw/llms.txt Initialize KnowledgeRAG to index knowledge from a directory. Supports hybrid retrieval (BM25, dense embeddings, RRF fusion) and optional LLM re-ranking. Retrieve relevant chunks using a query. ```python from pythonclaw.core.knowledge.rag import KnowledgeRAG from pythonclaw.core.llm.openai_compatible import OpenAICompatibleProvider provider = OpenAICompatibleProvider(api_key="sk-...", base_url="...", model_name="deepseek-chat") # Build RAG index from a directory of .md/.txt files rag = KnowledgeRAG( knowledge_dir="~/.pythonclaw/context/knowledge", provider=provider, # enables LLM re-ranker use_sparse=True, # BM25 use_dense=True, # sentence-transformers embeddings use_reranker=True, # LLM re-ranking of fused candidates dense_model="all-MiniLM-L6-v2", ) print(f"Indexed {len(rag)} chunks") # Retrieve top-k relevant chunks hits = rag.retrieve("refund policy", top_k=5) for hit in hits: print(f"[{hit['source']}]: {hit['content'][:100]}") # [policy.md]: Refunds are available within 30 days of purchase... ``` -------------------------------- ### MemoryManager Initialization and Operations Source: https://context7.com/ericwang915/pythonclaw/llms.txt Initialize MemoryManager to manage key-value memories. Supports storing, recalling (semantic or all), getting specific files, listing files, and forgetting entries. ```python from pythonclaw.core.memory.manager import MemoryManager mem = MemoryManager( memory_dir="~/.pythonclaw/context/memory", global_memory_dir=None, # set for per-group isolation with global fallback use_dense=False, # True = add embedding retrieval to recall ) # Store a fact result = mem.remember("User prefers Python 3.12", key="python_version_preference") # "Memory stored: [python_version_preference] = User prefers Python 3.12" # Retrieve by semantic query (BM25 + optional dense) result = mem.recall("programming preferences") # "- python_version_preference: User prefers Python 3.12" # Retrieve ALL memories all_mem = mem.recall("*") # Get a specific memory file content = mem.memory_get("MEMORY.md") # curated long-term memory file daily = mem.memory_get("2026-03-15.md") # specific daily log # List all memory files files = mem.list_files() # ["MEMORY.md", "2026-03-14.md", "2026-03-15.md"] # Delete a memory entry result = mem.forget("python_version_preference") # "Forgot: python_version_preference" # Read/write the INDEX.md system-info file index = mem.read_index() path = mem.write_index("## Environment\n- Server: Ubuntu 22.04\n- Python: 3.12") # Build boot context (auto-injected at session start) context = mem.boot_context(max_chars=3000) # Includes INDEX.md + MEMORY.md entries + 2 recent daily logs # Raw dict access (used by compaction) all_entries = mem.list_all() # {"python_version_preference": "User prefers Python 3.12", ...} ``` -------------------------------- ### Compaction module for context window management Source: https://context7.com/ericwang915/pythonclaw/llms.txt Provides standalone functions for summarizing conversation history, flushing key facts to memory, and persisting compaction audit logs. Useful for managing token limits. ```python from pythonclaw.core.compaction import ( compact, memory_flush, estimate_tokens, persist_compaction, messages_to_text, DEFAULT_AUTO_THRESHOLD_TOKENS, # 6000 tokens DEFAULT_RECENT_KEEP, # 6 messages ) messages = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the largest prime under 100?"}, {"role": "assistant", "content": "The largest prime under 100 is 97."}, # ... many more messages ... ] # Estimate token count (character-based: 1 token ≈ 4 chars) tokens = estimate_tokens(messages) print(f"~{tokens} tokens in context") # Run compaction (summarize old messages, keep recent ones verbatim) new_messages, summary = compact( messages=messages, provider=provider, memory=mem_manager, # optional: flush facts to long-term memory first recent_keep=6, instruction="focus on decisions and open tasks", log_path="~/.pythonclaw/context/compaction/history.jsonl", ) print(summary) # "User asked about primes. Established that 97 is the largest prime under 100. # User then asked about Fibonacci — answered with the formula..." # Flush facts to memory without full compaction from pythonclaw.core.memory.manager import MemoryManager mem = MemoryManager() count = memory_flush(messages[1:10], provider, mem) print(f"Saved {count} facts to long-term memory") ``` -------------------------------- ### Get YouTube Video Transcript Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/data/youtube/SKILL.md Fetch the full transcript or subtitles for a YouTube video by using the 'transcript' command. Transcript availability depends on whether the video has captions. ```bash python {skill_path}/youtube_info.py transcript ``` -------------------------------- ### Text-to-Speech with edge-tts Engine Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/media/tts/SKILL.md Utilize the edge-tts engine for potentially higher quality voices. Ensure `edge-tts` is installed and specify the desired voice using the `--voice` option. ```bash python {skill_path}/speak.py "Hello world" --engine edge --voice en-US-AriaNeural ``` -------------------------------- ### List Obsidian Notes in Folder Source: https://github.com/ericwang915/pythonclaw/blob/main/pythonclaw/templates/skills/productivity/obsidian/SKILL.md Lists all notes within a specified folder path in your Obsidian vault. ```bash python {skill_path}/obsidian_vault.py list "folder/path" ```