# How Cohort Analysis Functions in the /analyze-cohorts Command: A Complete Guide

> Discover how the /analyze-cohorts command uses cohort analysis to generate retention reports and actionable insights from user activity data. Explore the complete guide.

- Repository: [Pawel Huryn/pm-skills](https://github.com/phuryn/pm-skills)
- Tags: deep-dive
- Published: 2026-06-27

---

**The `/analyze-cohorts` command orchestrates a five-step conversational workflow that processes user activity data through the `cohort-analysis` skill to generate retention reports and actionable insights.**

The `pm-skills` repository provides product managers with structured commands for data-driven decision making. Understanding how **cohort analysis** functions within this system reveals a sophisticated architecture that bridges natural language interaction with advanced Pandas-based analytics. The command workflow is defined in [`pm-data-analytics/commands/analyze-cohorts.md`](https://github.com/phuryn/pm-skills/blob/main/pm-data-analytics/commands/analyze-cohorts.md) and delegates computational heavy lifting to the dedicated `cohort-analysis` skill.

## Input Handling: Data Uploads and Natural Language Requests

The `/analyze-cohorts` command accepts two distinct input modalities according to the invocation block in [`pm-data-analytics/commands/analyze-cohorts.md`](https://github.com/phuryn/pm-skills/blob/main/pm-data-analytics/commands/analyze-cohorts.md). Users may upload structured data files containing user-level activity records, or provide natural-language descriptions of the desired analytical scope.

This dual-input design accommodates varying data maturity levels. Teams with immediate access to user activity data can upload CSV, Excel, or JSON files for instant processing. Teams in the planning phase can describe analytical needs (e.g., "Monthly retention for users who signed up in Jan-Jun, grouped by acquisition channel") to receive implementation templates.

```text

# Basic usage with a CSV upload

/analyze-cohorts [upload a CSV of user activity data]

# Textual request – no file needed

/analyze-cohorts Monthly retention for users who signed up in Jan‑Jun, grouped by acquisition channel

# Guided assistance

/analyze-cohorts Help me set up a cohort analysis for our onboarding redesign

```

## Cohort Definition: Configuring Retention Parameters

After input validation, the command enters an interactive configuration phase documented under *Step 2: Define Cohorts* in the command specification. The system prompts users to define:

- **Cohort grouping dimensions** (e.g., signup month, acquisition channel, plan tier)
- **Retention events** (e.g., return visits, feature adoption, transactions)
- **Observation periods** and analysis timeframes

These parameters determine how the **cohort analysis** segments users and calculates survival rates. The conversational interface ensures technical and non-technical stakeholders align on analytical boundaries before computation begins.

## Analysis Execution: The Cohort-Analysis Skill Pipeline

The command delegates all computation to the **`cohort-analysis`** skill, implemented in [`pm-data-analytics/skills/cohort-analysis/SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/pm-data-analytics/skills/cohort-analysis/SKILL.md). This skill bifurcates logic based on data availability.

### Data-Backed Analysis with Pandas

When user activity data is provided, the skill executes a Pandas-based pipeline that:

1. Validates and cleans the uploaded dataset for schema compliance
2. Computes cohort assignment tables based on defined dimensions
3. Calculates period-over-period retention rates and survival metrics
4. Generates retention curves, heatmaps, and feature-adoption visualizations
5. Flags anomalies and seasonal effects in the cohort progression

The skill returns structured DataFrames and visualization assets that feed into the reporting layer.

### Template Generation for Data Warehouses

When operating without uploaded files, the skill drafts SQL query templates and spreadsheet frameworks. These artifacts enable data engineering teams to execute the equivalent **cohort analysis** against their data warehouse, ensuring reproducibility once data becomes available.

## Report Generation: Retention Tables and Visualizations

Following computation, the command assembles results into a comprehensive markdown report structured according to *Step 4: Generate Report* in [`pm-data-analytics/commands/analyze-cohorts.md`](https://github.com/phuryn/pm-skills/blob/main/pm-data-analytics/commands/analyze-cohorts.md). Standard outputs include:

- **Cohort summary tables** displaying group sizes and period-by-period retention percentages
- **Visual assets** including retention heatmaps and trend line charts (when visualization is requested)
- **Key findings and recommendations** derived from pattern recognition in the retention curves
- **Follow-up SQL snippets** for deeper investigation into specific cohort behaviors

The generated report serves as a standalone analytical artifact suitable for stakeholder presentations or strategic documentation.

## Next Steps: Iterative Cohort Analysis

The workflow concludes with optional follow-up actions outlined in *Step 5: Offer Next Steps* within the command documentation. The system can suggest:

- **Further segmentation** to isolate high-performing cohort characteristics
- **Metric alerts** for monitoring retention drops in real-time
- **Experiment design** templates for A/B testing interventions on specific cohorts

This iterative approach transforms the command from a one-time analysis tool into a continuous product intelligence system.

## Summary

- The `/analyze-cohorts` command in `phuryn/pm-skills` provides a five-step workflow covering input handling, cohort definition, analysis execution, report generation, and next-step recommendations.
- Input flexibility allows both direct data uploads (CSV/Excel/JSON) and natural-language analytical requests.
- The **`cohort-analysis`** skill implements core logic in [`pm-data-analytics/skills/cohort-analysis/SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/pm-data-analytics/skills/cohort-analysis/SKILL.md), using Pandas for data processing and SQL templating for warehouse queries.
- Generated reports include cohort tables, retention visualizations, actionable insights, and follow-up SQL snippets.
- The conversational interface guides users through technical configuration while maintaining accessibility for non-technical stakeholders.

## Frequently Asked Questions

### What file formats does the /analyze-cohorts command support?

The command accepts CSV, Excel, and JSON files containing user-level activity data. These formats are validated and processed through the Pandas-based pipeline in the `cohort-analysis` skill before cohort tables are computed.

### Can I run cohort analysis without uploading data?

Yes. When invoked with natural language descriptions alone, the command generates SQL query templates and spreadsheet frameworks. These artifacts allow data teams to execute the analysis against their data warehouse without requiring immediate file uploads.

### Where is the retention calculation logic implemented?

The retention calculation logic resides in [`pm-data-analytics/skills/cohort-analysis/SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/pm-data-analytics/skills/cohort-analysis/SKILL.md). This skill handles cohort assignment, period-over-period retention rate computation, and anomaly detection using Pandas DataFrames.

### How does the command handle cohort segmentation?

During *Step 2: Define Cohorts*, the command interactively prompts users to specify segmentation dimensions such as signup month, acquisition channel, or plan tier. These parameters are passed to the analysis skill to determine how users are grouped and compared.