Skip to main content
rule CX Codex

date-calculation — Claude Code rule: what it does, how to install

date-calculation stops the assistant from calculating dates mentally by enforcing system tools like date and python3. Helps avoid arithmetic mistakes on leap years and intervals.

MIT ★ 880 updated 2026-09-03

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/date-calculation.md
Open on GitHub

What date-calculation does

Language models regularly hallucinate date arithmetic. This rule blocks mental calculations, forbidding the assistant from guessing weekdays or manual business day intervals.

Every calculation must run through system binaries. The instructions provide platform-specific date commands for macOS and Linux to handle offsets, while directing complex duration arithmetic to python3 one-liners using datetime.

What it helps with

  • find the weekday for a specific date via the date utility
  • calculate day intervals between two dates using python3
  • determine target dates N days in the future or past
  • prevent arithmetic hallucinations around leap years and month ends

Example prompts for the agent

  • Find out what day of the week March 15, 2026 falls on.
  • Calculate the number of days between February 6, 2026 and December 31, 2026.
  • Show me the date exactly 30 days from today.

How to install date-calculation

Manually: put the files in place

.claude/rules/date-calculation.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about date-calculation

How do I install date-calculation in Claude Code?

Create the file at .claude/rules/date-calculation.md inside your repository and add the rule contents.

What does date-calculation do?

It forces Claude Code to run terminal commands like date or python3 for calendar math instead of doing arithmetic in memory.

Which tools are required for date calculations under this rule?

The rule relies on the system date utility across macOS and Linux, as well as python3 with the standard datetime module for multi-date spans.

Source text

date-calculation.md · MIT
# Date & Time Calculation (CRITICAL)

## Absolute Rule

NEVER calculate dates/times mentally. ALWAYS use system tools.

LLMs frequently make errors in date arithmetic. Use Bash or Python for ALL date calculations: day-of-week, durations, D-day, leap years, month-end, etc.

## Required Patterns

### Current Date/Time
```bash
date '+%Y-%m-%d %A %H:%M:%S %Z'
```

### Day of Week (macOS)
```bash
date -j -f '%Y-%m-%d' '2026-03-15' '+%A'
```

### Day of Week (Linux)
```bash
date -d '2026-03-15' '+%A'
```

### N Days From Now (macOS)
```bash
date -j -v+30d '+%Y-%m-%d %A'    # 30 days later
date -j -v-7d '+%Y-%m-%d %A'     # 7 days ago
```

### N Days From Now (Linux)
```bash
date -d '+30 days' '+%Y-%m-%d %A'    # 30 days later
date -d '-7 days' '+%Y-%m-%d %A'     # 7 days ago
```

### Complex Date Calculations (Python)
```bash
python3 -c "
from datetime import datetime, timedelta
# Days between two dates
d1 = datetime(2026, 2, 6)
d2 = datetime(2026, 12, 31)
print(f'{(d2-d1).days} days')
"
```

## Forbidden

- Mental arithmetic for dates
- Guessing day-of-week
- Manual business day calculations

## Required

- Always use `date` command or `python3`

© sangrokjung · MIT · sangrokjung/claude-forge

Similar IDE rules

All IDE rules for Agent setup: memory, context, orchestration →

From the same set44

The whole set →
update-codemaps The update-codemaps command examines a project’s structure and refreshes architecture maps in codemaps/. Use it when code changes need matching documentation. CX Codex +1 ★ 880repo stars update-docs update-docs rebuilds docs/CONTRIB.md and docs/RUNBOOK.md from package.json and .env.example, then reports which docs have gone stale. CX Codex +1 ★ 880repo stars testing testing enforces a strict TDD workflow in Claude Code with an 80% coverage floor, Playwright E2E suites, and three test tiers. CX Codex +1 ★ 880repo stars refactor-clean The refactor-clean command finds unused code, proposes cautious deletions, and checks the test suite around every change. CX Codex +1 ★ 880repo stars korean-character-count korean-character-count counts graphemes, lines, and UTF-8 bytes in Korean text by grapheme cluster rules, for self-intro forms with strict limits. CX Codex +1 ★ 880repo stars loop-forge loop-forge converts a single-line routine task into a reusable slash command equipped with safety gates and evaluation checks. CX Codex +1 ★ 880repo stars korean-spell-check korean-spell-check — a Claude Code skill that checks Korean spelling and returns edits instead of a rewritten draft. Long input gets split into chunks before it goes out. CX Codex +1 ★ 880repo stars instinct-status Review learned instincts with their confidence levels, domains, and sources. Use the command to inspect what the agent has picked up from its observations. CX Codex +1 ★ 880repo stars

Project sponsors

Companies that keep this analytics open