Tickd.ai
← The Tickd Guide

Tutorials & Guides

How to Build an Automated Slack Status Updater Using Claude 3.5 Sonnet and Python to Reflect Your Live Git Commits

Ditch the boring 'In a meeting' or generic 'Writing code' Slack statuses. Build a smart local Python automation that parses your latest Git commits, uses Claude to write a witty status, and updates Slack via API.

Updated 10/30/2026

Your Slack Status is Boring

We’ve all seen the default Slack statuses. A coffee cup icon next to "Focusing," or a generic calendar icon next to "In a meeting." It’s corporate, it’s dry, and it tells your team absolutely nothing about what you are actually working on. If you're cracking open database schemas, your status should say so. If you’re debugging CSS grid alignment for the fourth consecutive hour, your team deserves to know (or at least know not to disturb you).

Instead of updating this manually, we can build a simple local Python script that monitors your active development workflows, pipes your recent Git commits to Claude 3.5 Sonnet, and programmatically updates your Slack status with a clever, context-aware summary and custom emoji.

Let's get this running so your Slack profile accurately reflects what makes your developer gears tick.

Set up your AI once so you repeat yourself less.

Tickd is independent and not affiliated with any AI company.

Try AI Setup Profile

Why Claude 3.5 Sonnet?

To make this automation fun, we need a language model with a high degree of nuance, wit, and brevity. Anthropic's /platforms/claude is the industry gold standard for creative engineering tasks. It understands tone exceptionally well, which is crucial when compressing a messy, technical commit message into a clean, single-sentence status with an appropriate emoji representation.

Should you run into any credential problems or API limits during setup, check out our debugging hub at /platforms/claude/articles.

Prerequisites

Before we write any Python, make sure you have the following ready:

  • Python 3.8+ installed on your system
  • An Anthropic API key with some credits
  • A Slack User Token (not a bot token) with the users.profile:write scope. This allows the script to update your personal profile, rather than posting messages as a separate bot. You can create an application on the Slack API dashboard and install it to your workspace to obtain this token.

Step 1: Setting Up Your Python Environment

Create a new folder for your script, set up a virtual environment, and install the necessary dependencies:

`bash mkdir slack-git-status cd slack-git-status python3 -m venv venv source venv/bin/activate pip install anthropic slack_sdk python-dotenv `

Next, create a .env file to hold your sensitive credentials:

`env ANTHROPIC_API_KEY=your_anthropic_api_key_here SLACK_USER_TOKEN=xoxp-your-user-token-here `

Note: User tokens in Slack start with `xoxp-`, while bot tokens start with `xoxb-`. Make sure you use the user token so that the script operates on your personal profile.

Step 2: Reading Recent Git Commits

Our script needs to grab your latest local commit. We will write a utility function that executes a quick git log command to fetch the most recent commit hash and message from whichever repository directory we run the script in.

Create status_updater.py and add the initial Git code:

`python import os import subprocess import sys from dotenv import load_dotenv from anthropic import Anthropic from slack_sdk import WebClient from slack_sdk.errors import SlackApiError

load_dotenv()

def get_latest_commit(): try: # Get the hash and message of the most recent commit log_format = "%h - %s" commit_info = subprocess.check_output( ["git", "log", "-1", f"--pretty=format:{log_format}"], stderr=subprocess.DEVNULL, text=True ).strip() return commit_info except subprocess.CalledProcessError: # Not currently in a Git repository or Git is uninitialized return None `

Step 3: Drafting the Perfect Status with Claude

Now, we will interface with Anthropic's Claude 3.5 Sonnet. We want the model to analyze the raw commit and generate a humorous, clear, and highly specific status update that is no longer than 100 characters (the Slack hard limit).

Let’s set up our prompt logic to extract the best possible results. For more details on prompt engineering structures, view our guide on /prompts.

`python def generate_slack_status(commit_message): anthropic = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY")) prompt = f""" Analyze this recent Git commit message: "{commit_message}" Your job is to generate a clever, light-hearted Slack status and a matching Slack emoji based on this work. Constraints: 1. The status must be under 80 characters. 2. It must represent what the developer is actively doing. 3. Choose a common Slack emoji shortcode (e.g., :sparkles:, :bug:, :coffee:, :shrug:, :cat2:). 4. Output format must be EXACTLY: emoji_code | status_text 5. Keep the tone warm, witty, and developer-centric. Example Output: :scissors: | Snip-snapping dead code from production """ try: message = anthropic.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=100, temperature=0.7, messages=[ {"role": "user", "content": prompt} ] ) return message.content[0].text.strip() except Exception as e: print(f"Error generating status via Claude API: {e}") return None `

Step 4: Pushing the Status to Slack

Once we have our structured response from Claude, we parse the emoji and the status string and send it directly to Slack's profile API endpoint.

`python def update_slack_status(emoji, text): client = WebClient(token=os.getenv("SLACK_USER_TOKEN")) try: # Format profile updates correctly as a dictionary payload profile_data = { "status_text": text, "status_emoji": emoji, "status_expiration": 0 # 0 means the status doesn't expire automatically } response = client.users_profile_set(profile=profile_data) if response["ok"]: print(f"Success! Status updated to: {emoji} {text}") else: print("Failed to update Slack status:", response) except SlackApiError as e: print(f"Slack API Error: {e.response['error']}") `

Step 5: Tying it All Together

Now we create our primary orchestrator that reads the arguments, verifies environment variables, and executes the code chain:

`python def main(): if not os.getenv("ANTHROPIC_API_KEY") or not os.getenv("SLACK_USER_TOKEN"): print("Error: Missing credentials. Please check your .env file.") sys.exit(1) commit = get_latest_commit() if not commit: print("No active git commits detected here. Navigate to a git repo.") sys.exit(1) print(f"Found latest commit: '{commit}'") print("Asking Claude to whip up a status update...") claude_response = generate_slack_status(commit) if not claude_response: sys.exit(1) try: # Parse 'emoji | status' format from response emoji, status_text = claude_response.split("|", 1) emoji = emoji.strip() status_text = status_text.strip() # Fallback if Claude hallucinated formatting if not emoji.startswith(":") or not emoji.endswith(":"): emoji = ":keyboard:" update_slack_status(emoji, status_text) except ValueError: print(f"Failed to parse Claude output: '{claude_response}'. Falling back to default format.") update_slack_status(":keyboard:", claude_response[:70])

if __name__ == "__main__": main() `

Automate It with a Git Hook

Manually calling this script after every commit defeats the purpose of automation. To make this set-and-forget, write a local post-commit hook inside your active Git projects.

Create a file inside your project directory at .git/hooks/post-commit:

`bash #!/bin/bash # Run the Python updater in the background so it doesn't block the terminal exit source /path/to/your/slack-git-status/venv/bin/activate python /path/to/your/slack-git-status/status_updater.py & `

Make sure to run chmod +x .git/hooks/post-commit to give the script execution permissions.

Now, every single time you type git commit -m "...", your Slack status will silently adjust itself in the background. Your teammates will instantly see whether you’re fixing structural database schemas or battling CSS z-index stack errors, all without you ever needing to click outside your development terminal.

claudepythonautomationslack-apitutorials

Keep going

Build something with the prompt generator, decode the jargon in the glossary, or compare the tools on our platform deep-dives.