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
npx skills add benchflow-ai/skillsbench --skill trend-analysis -a claude-codeWhat 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-code2Manually: put the files in place
~/.claude/skills/trend-analysis/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/trend-analysis/
1Skills CLI (Vercel)
npx skills add benchflow-ai/skillsbench --skill trend-analysis -a codex2Manually: put the files in place
.agents/skills/trend-analysis/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add benchflow-ai/skillsbench --skill trend-analysis -a cursor2Manually: put the files in place
.cursor/skills/trend-analysis/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install benchflow-ai/skillsbench tasks/lake-warming-attribution/environment/skills/trend-analysis2Manually: put the files in place
.github/skills/trend-analysis/SKILL.md1Skills CLI (Vercel)
npx skills add benchflow-ai/skillsbench --skill trend-analysis -a gemini-cli2Platform CLI
gemini skills install https://github.com/benchflow-ai/skillsbench --path tasks/lake-warming-attribution/environment/skills/trend-analysisManually: put the files in place
.devin/skills/trend-analysis/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add benchflow-ai/skillsbench --skill trend-analysis -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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