Post a daily Slack leaderboard of rep activity from HubSpot using a Claude Code skill
Install this skill
Download the skill archive and extract it into your .claude/skills/ directory.
rep-leaderboard.skill.zipThis skill works with any agent that supports the Claude Code skills standard, including Claude Code, Claude Cowork, OpenAI Codex, and Google Antigravity.
- One of the agents listed above
- HubSpot private app with
crm.objects.contacts.readand engagement scopes (crm.objects.calls.read,crm.objects.emails.read,crm.objects.meetings.read) - Slack bot with
chat:writepermission, added to the target channel
Why a Claude Code skill?
The other approaches in this guide are deterministic: they run the same leaderboard every time. An Claude Code skill is different. You tell Claude what you want in plain language, and the skill gives it enough context to do it reliably.
That means you can say:
- "Post today's rep leaderboard to Slack"
- "Show me just SDR activity for the past 3 days"
- "Who had the most meetings booked this week?"
The skill contains workflow guidelines, API reference materials, and a message template that the agent reads on demand. When you invoke the skill, Claude reads these files, writes a script on the fly, runs it, and reports results. If you ask for something different next time — a different time window, a filtered team, weighted scoring — the agent adapts without you touching any code.
How it works
The skill directory has three parts:
SKILL.md— workflow guidelines telling the agent what steps to follow, which env vars to use, and what pitfalls to avoidreferences/— HubSpot API patterns (engagement search endpoints, owner endpoints, request/response shapes) so the agent calls the right APIs with the right parameterstemplates/— a Slack Block Kit template so leaderboard messages are consistently formatted across runs
When invoked, the agent reads SKILL.md, consults the reference and template files as needed, writes a Python script, executes it, and reports what it posted. The reference files act as guardrails — the agent knows exactly which endpoints to hit and what the responses look like, so it doesn't have to guess.
What is a Claude Code skill?
An Claude Code skill is a reusable command you add to your project that Claude Code can run on demand. Skills live in a .claude/skills/ directory and are defined by a SKILL.md file that tells the agent what the skill does, when to run it, and what tools it's allowed to use.
In this skill, the agent doesn't run a pre-written script. Instead, SKILL.md provides workflow guidelines and points to reference files — API documentation, message templates — that the agent reads to generate and execute code itself. This is the key difference from a traditional script: the agent can adapt its approach based on what you ask for while still using the right APIs and message formats.
Once installed, you can invoke a skill as a slash command (e.g., /rep-leaderboard), or the agent will use it automatically when you give it a task where the skill is relevant. Skills are portable — anyone who clones your repo gets the same commands.
Step 1: Create the skill directory
mkdir -p .claude/skills/rep-leaderboard/{templates,references}This creates the layout:
.claude/skills/rep-leaderboard/
├── SKILL.md # workflow guidelines + config
├── templates/
│ └── slack-leaderboard.md # Block Kit template for Slack messages
└── references/
└── hubspot-engagements-api.md # HubSpot API patternsStep 2: Write the SKILL.md
Create .claude/skills/rep-leaderboard/SKILL.md:
---
name: rep-leaderboard
description: Generate a daily rep activity leaderboard from HubSpot and post it to Slack
disable-model-invocation: true
allowed-tools: Bash, Read
---
## Goal
Fetch yesterday's rep activity (calls, emails, meetings) from HubSpot, rank reps by total activity, and post a formatted leaderboard to Slack.
## Configuration
Read these environment variables:
- `HUBSPOT_ACCESS_TOKEN` — HubSpot private app token (required)
- `SLACK_BOT_TOKEN` — Slack bot token starting with xoxb- (required)
- `SLACK_CHANNEL_ID` — Slack channel ID starting with C (required)
Default lookback window: 1 day (yesterday midnight to today midnight UTC). The user may request a different window.
## Workflow
1. Validate that all required env vars are set. If any are missing, print which ones and exit.
2. Fetch the owner roster from HubSpot to build an owner ID → display name map. See `references/hubspot-engagements-api.md` for the endpoint.
3. Compute yesterday's midnight-to-midnight UTC timestamp range in milliseconds.
4. Search for calls, emails, and meetings logged yesterday using the HubSpot CRM Search API. See `references/hubspot-engagements-api.md` for request and response formats.
5. Aggregate per-owner counts across all three activity types. Rank by total descending.
6. Post a leaderboard to Slack using the Block Kit format in `templates/slack-leaderboard.md`. Assign medal emojis to the top 3.
7. Print a summary of how many reps were ranked and the leaderboard posted.
## Important notes
- HubSpot engagement objects use `hs_timestamp` for the activity date, not `createdate`. Filter on `hs_timestamp` for accurate date matching.
- Timestamps must be in Unix **milliseconds** (13 digits). Passing seconds (10 digits) returns zero results with no error.
- Activities without a `hubspot_owner_id` should be excluded from the ranking.
- The Search API returns max 100 results per request. Use the `after` cursor from `paging.next.after` to paginate if needed.
- The Search API rate limit is 5 requests per second. Add a small delay between searches if needed.
- Use the `requests` library for HTTP calls and `slack_sdk` for Slack. Install them with pip if needed.Understanding the SKILL.md
Unlike the script-based approach, this SKILL.md doesn't contain a Run: command pointing to a script. Instead, it provides:
| Section | Purpose |
|---|---|
| Goal | Tells the agent what outcome to produce |
| Configuration | Which env vars to read and what defaults to use |
| Workflow | Numbered steps with pointers to reference files |
| Important notes | Non-obvious context that prevents common mistakes |
The allowed-tools: Bash, Read setting lets the agent both read reference files and execute code. The agent writes its own script based on the workflow steps and reference materials.
Step 3: Add reference files
templates/slack-leaderboard.md
Create .claude/skills/rep-leaderboard/templates/slack-leaderboard.md:
# Slack Leaderboard Template
Use this Block Kit structure for the daily rep activity leaderboard.
## Block Kit JSON
```json
{
"channel": "<SLACK_CHANNEL_ID>",
"text": "Rep Activity Leaderboard",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "🏆 Rep Activity Leaderboard"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Activity for <date_string>"
}
]
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<ranked_lines>"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "C = Calls | E = Emails | M = Meetings"
}
]
}
]
}
```
## Ranking format
Each rep line should follow this format:
- Top 3: `🥇 *Name* — X activities (YC ZE WM)`
- Others: `4. *Name* — X activities (YC ZE WM)`
Where C = calls, E = emails, M = meetings.
## Notes
- The top-level `text` field is required by Slack as a fallback for notifications.
- To customize, you can add team totals, weighted scores, or trend indicators.references/hubspot-engagements-api.md
Create .claude/skills/rep-leaderboard/references/hubspot-engagements-api.md:
# HubSpot Engagements API Reference
## Get owners
Build an owner ID → display name map for the leaderboard.
**Request:**
```
GET https://api.hubapi.com/crm/v3/owners?limit=100
Authorization: Bearer <HUBSPOT_ACCESS_TOKEN>
```
**Response shape:**
```json
{
"results": [
{
"id": "12345",
"email": "sarah@example.com",
"firstName": "Sarah",
"lastName": "Chen"
}
]
}
```
Build the name as `firstName + " " + lastName`. Fall back to `email` if both are empty.
## Search for engagements
Use the CRM Search API to find calls, emails, or meetings within a time range.
**Request:**
```
POST https://api.hubapi.com/crm/v3/objects/<object_type>/search
Authorization: Bearer <HUBSPOT_ACCESS_TOKEN>
Content-Type: application/json
```
Where `<object_type>` is one of: `calls`, `emails`, `meetings`.
**Body:**
```json
{
"filterGroups": [
{
"filters": [
{
"propertyName": "hs_timestamp",
"operator": "GTE",
"value": "<start_timestamp_ms>"
},
{
"propertyName": "hs_timestamp",
"operator": "LT",
"value": "<end_timestamp_ms>"
}
]
}
],
"properties": ["hs_timestamp", "hubspot_owner_id"],
"limit": 100
}
```
- `value` is a Unix timestamp in **milliseconds** (multiply seconds by 1000).
- `limit` max is 100. If there are more results, use the `after` cursor from `paging.next.after` to paginate.
**Response shape:**
```json
{
"total": 15,
"results": [
{
"id": "67890",
"properties": {
"hs_timestamp": "2026-03-04T14:30:00.000Z",
"hubspot_owner_id": "12345"
}
}
],
"paging": {
"next": {
"after": "100"
}
}
}
```Step 4: Test the skill
Invoke the skill conversationally:
/rep-leaderboardClaude will read the SKILL.md, check the reference files, write a script, install any missing dependencies, run it, and report the results. A typical run looks like:
Fetching owners... found 8 reps
Fetching yesterday's activities...
Found: 42 calls, 67 emails, 12 meetings
Posting leaderboard to Slack...
Done. Posted leaderboard with 8 reps ranked.What the Slack leaderboard looks like
🏆 Rep Activity Leaderboard
Yesterday — Mar 3, 2026
🥇 Sarah K. — 14 calls, 22 emails, 3 meetings
🥈 James R. — 12 calls, 18 emails, 2 meetings
🥉 Maria L. — 10 calls, 25 emails, 2 meetings
4. David P. — 8 calls, 15 emails, 1 meeting
5. Alex T. — 6 calls, 12 emails, 1 meeting
Team Total: 50 calls, 92 emails, 9 meetings
Because the agent generates code on the fly, you can also make ad hoc requests:
- "Show me just SDR activity for the last 3 days" — the agent adjusts the lookback window and filters by team
- "Who had the most meetings this week?" — the agent changes the ranking metric
- "Post the leaderboard with weighted scoring (meetings x3, calls x2, emails x1)" — the agent adapts the formula
Make sure at least one rep has logged a call, email, or meeting in HubSpot within the lookback window. If no activities were logged yesterday, the skill correctly reports "No activity logged" — that's not an error.
Step 5: Schedule it (optional)
Option A: Cron + Claude CLI
# Run every weekday at 8 AM
0 8 * * 1-5 cd /path/to/your/project && claude -p "Run /rep-leaderboard" --allowedTools 'Bash(*)' 'Read(*)'Option B: GitHub Actions + Claude
name: Daily Rep Leaderboard
on:
schedule:
- cron: '0 13 * * 1-5' # 8 AM ET = 1 PM UTC, weekdays only
workflow_dispatch: {}
jobs:
leaderboard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@v1
with:
prompt: "Run /rep-leaderboard"
allowed_tools: "Bash(*),Read(*)"
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
HUBSPOT_ACCESS_TOKEN: ${{ secrets.HUBSPOT_ACCESS_TOKEN }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}Option C: Cowork Scheduled Tasks
Claude Desktop's Cowork supports built-in scheduled tasks. Open a Cowork session, type /schedule, and configure the cadence — hourly, daily, weekly, or weekdays only. Each scheduled run has full access to your connected tools, plugins, and MCP servers.
Scheduled tasks only run while your computer is awake and Claude Desktop is open. If a run is missed, Cowork executes it automatically when the app reopens. For always-on scheduling, use GitHub Actions (Option B) instead. Available on all paid plans (Pro, Max, Team, Enterprise).
0 13 * * 1-5 runs at 1 PM UTC (8 AM ET) on weekdays. GitHub Actions cron may also have up to 15 minutes of delay. For time-sensitive daily posts, use cron on your own server.
Troubleshooting
When to use this approach
- You want conversational flexibility — ad hoc queries like "who had the most calls this week?" alongside daily leaderboards
- You want on-demand leaderboards during standups or team meetings, not just scheduled posts
- You're already using Claude Code and want skills that integrate with your workflow
- You want to run tasks in the background via Claude Cowork while focusing on other work
- You prefer guided references over rigid scripts — the agent adapts while staying reliable
When to switch approaches
- You need reliable daily scheduling with zero manual intervention → use n8n or the code approach
- You want a no-code setup with a visual builder → use Zapier or Make
- You need leaderboards running 24/7 with zero cost and no LLM usage → use the Code + Cron approach
Common questions
Why not just use a script?
A script runs the same way every time. The Claude Code skill adapts to what you ask — different lookback windows, filtered teams, weighted scoring, different channels. The reference files ensure it calls the right APIs even when improvising, so you get flexibility without sacrificing reliability.
Does this use Claude API credits?
Yes. The agent reads skill files and generates code each time. Typical cost is $0.01-0.05 per invocation depending on how many engagements are returned and how much the agent needs to read. The HubSpot and Slack APIs themselves are free.
Can I run this skill on a schedule without a server?
Yes. GitHub Actions (Option B in Step 5) runs Claude on a cron schedule using GitHub's infrastructure. The free tier includes 2,000 minutes/month — more than enough for daily weekday runs.
Can I use this skill in a different repo or share it with my team?
Yes. The .claude/skills/ directory is portable — anyone who clones the repo gets the same skill. They just need to set the environment variables and have Claude Code installed. The skill works in any project directory as long as the .claude/skills/rep-leaderboard/ path exists.
Cost
- Claude API — $0.01-0.05 per invocation (the agent reads files and generates code)
- HubSpot API — included in all plans, no per-call cost
- Slack API — included in all plans, no per-call cost
- GitHub Actions (if scheduled) — free tier includes 2,000 minutes/month
Looking to scale your AI operations?
We build and optimize automation systems for mid-market businesses. Let's discuss the right approach for your team.