Automate a weekly pipeline report with HubSpot and Slack using a Claude Code skill

low complexityCost: Usage-based
Compatible agents

This skill works with any agent that supports the Claude Code skills standard, including Claude Code, Claude Cowork, OpenAI Codex, and Google Antigravity.

Prerequisites
  • One of the agents listed above
  • HubSpot private app with crm.objects.deals.read and crm.schemas.deals.read scopes
  • Slack bot with chat:write permission, added to the target channel
Environment Variables
# HubSpot private app token (Settings > Integrations > Private Apps)
HUBSPOT_ACCESS_TOKEN=your_value_here
# Slack bot token starting with xoxb- (chat:write scope required)
SLACK_BOT_TOKEN=your_value_here
# Slack channel ID starting with C (right-click channel > View channel details)
SLACK_CHANNEL_ID=your_value_here

Why a Claude Code skill?

The other approaches in this guide are deterministic: they run the same pipeline report 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 this week's pipeline report to Slack"
  • "Show me just Enterprise pipeline deals over $100K"
  • "Which deals have been stale for more than 30 days?"

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 pipeline, a specific stage, deals by rep — the agent adapts without you touching any code.

How it works

The skill directory has three parts:

  1. SKILL.md — workflow guidelines telling the agent what steps to follow, which env vars to use, and what pitfalls to avoid
  2. references/ — HubSpot API patterns (deals search endpoint, pipelines endpoint, deal properties) so the agent calls the right APIs with the right parameters
  3. templates/ — a Slack Block Kit template so pipeline reports 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., /pipeline-report), 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/pipeline-report/{templates,references}

This creates the layout:

.claude/skills/pipeline-report/
├── SKILL.md                          # workflow guidelines + config
├── templates/
│   └── slack-pipeline-report.md      # Block Kit template for Slack messages
└── references/
    └── hubspot-deals-api.md          # HubSpot API patterns

Step 2: Write the SKILL.md

Create .claude/skills/pipeline-report/SKILL.md:

---
name: pipeline-report
description: Generate a weekly pipeline report from HubSpot and post it to Slack
disable-model-invocation: true
allowed-tools: Bash, Read
---
 
## Goal
 
Fetch all active deals from HubSpot, calculate pipeline metrics (total value, deals by stage, stale deals), and post a formatted report 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 pipeline: `default`. The user may request a specific pipeline ID.
 
## Workflow
 
1. Validate that all required env vars are set. If any are missing, print which ones and exit.
2. Fetch pipeline stage definitions from HubSpot to build a stage ID → label map. See `references/hubspot-deals-api.md` for the endpoint.
3. Search for all active deals in the pipeline. See `references/hubspot-deals-api.md` for the search endpoint and request format. Paginate if needed.
4. Calculate metrics: total pipeline value, deal counts by stage, and deals with no activity in the last 14 days (stale deals).
5. Post the report to Slack using the Block Kit format in `templates/slack-pipeline-report.md`.
6. Print a summary of total pipeline value, deal count, and stale deal count.
 
## Important notes
 
- Deal amounts may be null or empty. Treat missing amounts as $0.
- The Deals Search API returns max 100 results per request. Use the `after` cursor from `paging.next.after` to paginate.
- Use `hs_lastmodifieddate` (not `closedate`) to determine if a deal is stale.
- Stage IDs in deal properties are internal identifiers — map them to human-readable labels using the pipelines endpoint.
- The default pipeline ID is `default` in most HubSpot portals. If the user has renamed it, they may need to provide the pipeline ID.
- 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:

SectionPurpose
GoalTells the agent what outcome to produce
ConfigurationWhich env vars to read and what defaults to use
WorkflowNumbered steps with pointers to reference files
Important notesNon-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-pipeline-report.md

Create .claude/skills/pipeline-report/templates/slack-pipeline-report.md:

# Slack Pipeline Report Template
 
Use this Block Kit structure for the weekly pipeline report.
 
## Block Kit JSON
 
```json
{
  "channel": "<SLACK_CHANNEL_ID>",
  "text": "Weekly Pipeline Report",
  "blocks": [
    {
      "type": "header",
      "text": {
        "type": "plain_text",
        "text": "📊 Weekly Pipeline Report"
      }
    },
    {
      "type": "section",
      "fields": [
        {
          "type": "mrkdwn",
          "text": "*Total Pipeline*\n$<total_value>"
        },
        {
          "type": "mrkdwn",
          "text": "*Active Deals*\n<deal_count>"
        }
      ]
    },
    {
      "type": "divider"
    },
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "*Deals by Stage*\n<stage_lines>"
      }
    },
    {
      "type": "divider"
    },
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "⚠️ *At Risk (14+ days stale)*\n<stale_lines>"
      }
    },
    {
      "type": "context",
      "elements": [
        {
          "type": "mrkdwn",
          "text": "Generated <date_string>"
        }
      ]
    }
  ]
}
```
 
## Stage line format
 
Each stage line: `• Stage Name: X deals`
 
## Stale deal line format
 
Each stale deal line: `• Deal Name — $Amount (Xd stale)`
 
Show the top 5 stale deals, sorted by days stale descending.
 
## Notes
 
- The top-level `text` field is required by Slack as a fallback for notifications.
- Omit the "At Risk" section if there are no stale deals.
- Format dollar amounts with commas (e.g., $2,400,000).

references/hubspot-deals-api.md

Create .claude/skills/pipeline-report/references/hubspot-deals-api.md:

# HubSpot Deals API Reference
 
## Get pipeline stages
 
Build a stage ID → label map for the report.
 
**Request:**
 
```
GET https://api.hubapi.com/crm/v3/pipelines/deals
Authorization: Bearer <HUBSPOT_ACCESS_TOKEN>
```
 
**Response shape:**
 
```json
{
  "results": [
    {
      "id": "default",
      "label": "Sales Pipeline",
      "stages": [
        {
          "id": "appointmentscheduled",
          "label": "Appointment Scheduled"
        },
        {
          "id": "qualifiedtobuy",
          "label": "Qualified to Buy"
        }
      ]
    }
  ]
}
```
 
## Search for deals
 
Use the CRM Search API to find all active deals in a pipeline.
 
**Request:**
 
```
POST https://api.hubapi.com/crm/v3/objects/deals/search
Authorization: Bearer <HUBSPOT_ACCESS_TOKEN>
Content-Type: application/json
```
 
**Body:**
 
```json
{
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "pipeline",
          "operator": "EQ",
          "value": "default"
        }
      ]
    }
  ],
  "properties": ["dealname", "amount", "dealstage", "closedate", "hs_lastmodifieddate"],
  "sorts": [{"propertyName": "amount", "direction": "DESCENDING"}],
  "limit": 100
}
```
 
- `limit` max is 100. Use the `after` cursor from `paging.next.after` to paginate.
- `amount` may be null or empty for deals without a dollar value set.
- `hs_lastmodifieddate` is an ISO 8601 timestamp (e.g., `"2026-03-01T10:30:00.000Z"`).
- `dealstage` is an internal stage ID — map it using the pipelines endpoint above.
 
**Response shape:**
 
```json
{
  "total": 47,
  "results": [
    {
      "id": "12345",
      "properties": {
        "dealname": "Acme Corp — Enterprise",
        "amount": "150000",
        "dealstage": "qualifiedtobuy",
        "closedate": "2026-04-15T00:00:00.000Z",
        "hs_lastmodifieddate": "2026-02-20T14:30:00.000Z"
      }
    }
  ],
  "paging": {
    "next": {
      "after": "100"
    }
  }
}
```

Step 4: Test the skill

Invoke the skill conversationally:

/pipeline-report

Claude 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 pipeline stages... found 6 stages
Fetching deals... found 47 active deals
Calculating metrics...
  Total pipeline: $2,400,000
  Stale deals: 3 (14+ days without activity)
Posting report to Slack...
Done. 47 deals, $2.4M total pipeline.

What the Slack report looks like

What you'll get
#sales-leadership
Pipeline Botapp9:41 AM

📊 Weekly Pipeline Report

Total Pipeline: $2.4M across 47 deals

New This Week: 12 deals ($680K)

Moved Forward: 8 deals ($420K)

At Risk: 3 deals stale 14+ days ($310K)

Because the agent generates code on the fly, you can also make ad hoc requests:

  • "Show me just Enterprise pipeline deals over $100K" — the agent adds amount and name filters
  • "Which deals have been stale for more than 30 days?" — the agent adjusts the stale threshold
  • "Post a pipeline report broken down by sales rep" — the agent adds owner grouping
Test with real data

Make sure you have at least a few active deals in your pipeline. If no deals exist, the skill correctly reports "No active deals found" — that's not an error.

Step 5: Schedule it (optional)

Option A: Cron + Claude CLI

# Run every Monday at 8 AM
0 8 * * 1 cd /path/to/your/project && claude -p "Run /pipeline-report" --allowedTools 'Bash(*)' 'Read(*)'

Option B: GitHub Actions + Claude

name: Weekly Pipeline Report
on:
  schedule:
    - cron: '0 13 * * 1'  # 8 AM ET = 1 PM UTC, Mondays only
  workflow_dispatch: {}
jobs:
  report:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: anthropics/claude-code-action@v1
        with:
          prompt: "Run /pipeline-report"
          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).

GitHub Actions cron uses UTC

0 13 * * 1 runs at 1 PM UTC (8 AM ET) on Mondays. GitHub Actions cron may also have up to 15 minutes of delay.

Troubleshooting

When to use this approach

  • You want conversational flexibility — ad hoc queries like "show me just stale deals over $50K" alongside weekly reports
  • You want on-demand pipeline snapshots during leadership meetings or forecast calls
  • 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 weekly 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 reports 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 pipelines, stage-specific breakdowns, rep-level analysis, custom stale thresholds. 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 the number of deals 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 weekly runs.

Can I report across multiple pipelines?

Yes. Ask the agent to remove the pipeline filter or specify multiple pipeline IDs. The reference file documents the pipeline filter, so the agent knows how to adjust the query.

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.