Skip to main content
skill CX Codex

trend-analysis — Claude Code skill: what it does, how to install

trend-analysis guides agents in evaluating time series trends using linear regression and Sen's slope.

MIT 8 installs ★ 1,933 updated 2026-10-24

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add benchflow-ai/skillsbench --skill trend-analysis -a claude-code
Open on GitHub

What trend-analysis does

The skill provides guidelines and Python snippets for testing whether a metric trends upward or downward over time. It contrasts standard linear regression using scipy.stats.linregress with non-parametric alternatives from pymannkendall.

Inside, you will find rules for interpreting p-values, verifying assumptions like normality or homoscedasticity, and handling discrepancies between methods. For environmental records with outliers, the guide explicitly advises relying on Sen's slope with the Mann-Kendall test instead of least squares.

The calculation fails when dealing with fewer than 8 to 10 observations, producing NaN for p-values. Running the generated code requires Python with scipy, pandas, and pymannkendall installed in your project environment.

What it helps with

  • Determine if a variable shows significant long-term growth or decline
  • Compute Sen's slope and Mann-Kendall p-value on noisy data
  • Fit a linear regression line to annual metrics with standard error checks
  • Select the right statistical test when residuals violate normality

Example prompts for the agent

  • Analyze annual precipitation in precipitation.csv using Sen's slope
  • Fit a linear trend to my time series and report the p-value
  • Run a Mann-Kendall test on annual temperatures to see if the rise is significant

How to install trend-analysis

1Skills CLI (Vercel)

npx skills add benchflow-ai/skillsbench --skill trend-analysis -a claude-code

2Manually: put the files in place

~/.claude/skills/trend-analysis/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/trend-analysis/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about trend-analysis

How to install trend-analysis in Claude Code?

Run npx skills add benchflow-ai/skillsbench --skill trend-analysis -a claude-code. The file will be placed in ~/.claude/skills/trend-analysis/SKILL.md.

What does trend-analysis do?

It equips the coding agent with standard workflows to assess time series trends via parametric linear regression and non-parametric Mann-Kendall calculations.

Which Python libraries are needed to execute the examples?

The provided code patterns rely on scipy, pandas, and pymannkendall.

Source text

SKILL.md · MIT
---
name: trend-analysis
description: Detect long-term trends in time series data using parametric and non-parametric methods. Use when determining if a variable shows statistically significant increase or decrease over time.
license: MIT
---

# Trend Analysis Guide

## Overview

Trend analysis determines whether a time series shows a statistically significant long-term increase or decrease. This guide covers both parametric (linear regression) and non-parametric (Sen's slope) methods.

## Parametric Method: Linear Regression

Linear regression fits a straight line to the data and tests if the slope is significantly different from zero.
```python
from scipy import stats

slope, intercept, r_value, p_value, std_err = stats.linregress(years, values)

print(f"Slope: {slope:.2f} units/year")
print(f"p-value: {p_value:.2f}")
```

### Assumptions

- Linear relationship between time and variable
- Residuals are normally distributed
- Homoscedasticity (constant variance)

## Non-Parametric Method: Sen's Slope with Mann-Kendall Test

Sen's slope is robust to outliers and does not assume normality. Recommended for environmental data.
```python
import pymannkendall as mk

result = mk.original_test(values)

print(result.slope)  # Sen's slope (rate of change per time unit)
print(result.p)      # p-value for significance
print(result.trend)  # 'increasing', 'decreasing', or 'no trend'
```

### Comparison

| Method | Pros | Cons |
|--------|------|------|
| Linear Regression | Easy to interpret, gives R² | Sensitive to outliers |
| Sen's Slope | Robust to outliers, no normality assumption | Slightly less statistical power |

## Significance Levels

| p-value | Interpretation |
|---------|----------------|
| p < 0.01 | Highly significant trend |
| p < 0.05 | Significant trend |
| p < 0.10 | Marginally significant |
| p >= 0.10 | No significant trend |

## Example: Annual Precipitation Trend
```python
import pandas as pd
import pymannkendall as mk

# Load annual precipitation data
df = pd.read_csv('precipitation.csv')
precip = df['Precipitation'].values

# Run Mann-Kendall test
result = mk.original_test(precip)
print(f"Sen's slope: {result.slope:.2f} mm/year")
print(f"p-value: {result.p:.2f}")
print(f"Trend: {result.trend}")
```

## Common Issues

| Issue | Cause | Solution |
|-------|-------|----------|
| p-value = NaN | Too few data points | Need at least 8-10 years |
| Conflicting results | Methods have different assumptions | Trust Sen's slope for environmental data |
| Slope near zero but significant | Large sample size | Check practical significance |

## Best Practices

- Use at least 10 data points for reliable results
- Prefer Sen's slope for environmental time series
- Report both slope magnitude and p-value
- Round results to 2 decimal places

© benchflow-ai · MIT · benchflow-ai/skillsbench

Similar skills

All skills for Data and databases →

From the same set22

The whole set →
fjsp-baseline-repair-with-downtime-and-policy fjsp-baseline-repair-with-downtime-and-policy repairs flexible job shop schedules by resolving downtime conflicts, operation precedence issues, and budget constraints. CX Codex +1 32installs search-driving-distance search-driving-distance gives driving or taxi time, distance and a rough price between two cities, using the distance matrix CSV that comes with the skill. CX Codex +1 31installs glm-basics The glm-basics skill explains how to run the General Lake Model, read its input files, and adjust configuration values. Use it when setting up a lake temperature simulation. CX Codex +1 14installs pymatgen pymatgen handles crystal structure transformations, file conversions between CIF and POSCAR, symmetry analysis, and Materials Project queries. CX Codex +1 12installs threejs This skill maps Three.js scene groups to parts, then prepares per-part OBJ files or URDF links. Use it when a scene needs structured geometry export. CX Codex +1 8installs reflow-machine-maintenance-guidance reflow-machine-maintenance-guidance handles reflow oven upkeep questions by computing ramp rates, time above liquidus and conveyor limits from thermocouple logs, MES data and the handbook. CX Codex +1 5installs text-to-speech The text-to-speech skill guides TTS cleanup, loudness matching, and segment timing for video audio exports. CX Codex +1 4installs civ6lib civ6lib validates Civilization 6 district placement and computes adjacency bonuses. Use it when an agent needs to reason about city layouts and game rules. CX Codex +1 2installs

Project sponsors

Companies that keep this analytics open