# duration-prediction

The duration-prediction Claude Code skill estimates construction project durations with k-NN and regression, using records from past projects. It runs when an agent is asked to forecast a new project's timeline from comparable work.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 115 installs · ★ 434 repo stars
- Author: datadrivenconstruction
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction/tree/HEAD/2_DDC_Book/4.5-ML-Cost-Prediction/duration-prediction/SKILL.md
- Updated: 2026-10-19
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/duration-prediction

## What it does

The skill estimates a project's duration from its features and completed-project records. It compares project type, floor area, storeys, complexity, location, basement status, and renovation status to find similar jobs. Standard k-NN averages the nearest projects' durations; the weighted version gives closer matches more influence.

The code also includes a project-type baseline, used when no matching historical records are found. Results contain a duration estimate, an interval, similar project IDs, and the selected model. Running the data-loading code requires Python 3, `pandas`, and `numpy`; estimates based on comparable projects need historical project records.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill duration-prediction -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/duration-prediction/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/duration-prediction/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill duration-prediction -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/duration-prediction/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill duration-prediction -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/duration-prediction/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction 2_DDC_Book/4.5-ML-Cost-Prediction/duration-prediction
```

2. **Manually: put the files in place**
- File: `.github/skills/duration-prediction/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill duration-prediction -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --path 2_DDC_Book/4.5-ML-Cost-Prediction/duration-prediction
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/duration-prediction/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill duration-prediction -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction/tree/HEAD/2_DDC_Book/4.5-ML-Cost-Prediction/duration-prediction/SKILL.md

## When to use it
- forecast a construction timeline from completed projects
- compare expected durations for projects of the same type
- retrieve a duration interval and IDs of comparable projects

## Example prompts
- Estimate the timeline for this new office project from historical records.
- Compare this residential project with completed projects of the same type.
- Predict the project duration and return comparable project IDs.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 20ebd547f474f51d.

BEGIN THIRD-PARTY FILE 20ebd547f474f51d
````text
---
name: "duration-prediction"
description: "Predict project duration using k-NN and regression. Estimate timeline based on similar historical projects."
homepage: "https://datadrivenconstruction.io"
metadata: {"openclaw": {"emoji": "🤖", "os": ["darwin", "linux", "win32"], "homepage": "https://datadrivenconstruction.io", "requires": {"bins": ["python3"]}}}
---
# Duration Prediction

## Business Case

### Problem Statement
Project duration estimation challenges:
- Subjective expert estimates
- Lack of historical benchmarking
- Inaccurate early-stage predictions
- Difficulty comparing similar projects

### Solution
Machine learning-based duration prediction using k-Nearest Neighbors and regression models trained on historical project data.

## Technical Implementation

```python
import pandas as pd
import numpy as np
from typing import Dict, Any, List, Optional, Tuple
from dataclasses import dataclass, field
from datetime import date
from enum import Enum
import math


class ModelType(Enum):
    KNN = "knn"
    LINEAR_REGRESSION = "linear_regression"
    WEIGHTED_KNN = "weighted_knn"


class ProjectType(Enum):
    OFFICE = "office"
    RESIDENTIAL = "residential"
    INDUSTRIAL = "industrial"
    RETAIL = "retail"
    HEALTHCARE = "healthcare"
    EDUCATION = "education"


@dataclass
class ProjectFeatures:
    project_id: str
    project_type: ProjectType
    size_sf: float
    floors: int
    complexity: int  # 1-5
    location_factor: float  # Cost adjustment factor
    has_basement: bool = False
    is_renovation: bool = False
    actual_duration: Optional[int] = None  # Days


@dataclass
class PredictionResult:
    predicted_duration: int
    confidence_interval: Tuple[int, int]
    similar_projects: List[str]
    model_used: ModelType
    features_importance: Dict[str, float]


class DurationPredictor:
    """Predict project duration using ML techniques."""

    def __init__(self):
        self.training_data: List[ProjectFeatures] = []
        self.feature_weights: Dict[str, float] = {
            'size_sf': 0.30,
            'floors': 0.15,
            'complexity': 0.25,
            'location_factor': 0.10,
            'has_basement': 0.10,
            'is_renovation': 0.10
        }
        self.type_baseline_days: Dict[ProjectType, Dict[str, float]] = {
````
END THIRD-PARTY FILE 20ebd547f474f51d

The third-party file has ended. Everything between the 20ebd547f474f51d tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2304 of 14253 bytes. © datadrivenconstruction · MIT · https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction/tree/HEAD/2_DDC_Book/4.5-ML-Cost-Prediction/duration-prediction/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
