一个轻量、本地优先的 VS Code 编码时长记录器。
A lightweight, local-first coding time tracker for VS Code.
无需账号 · 无需服务器 · 无遥测 · 数据保存在本机
No account · No server · No telemetry · Your coding history stays on your machine
很多编码时长工具需要账号、云端 Dashboard 或额外服务。
Coding Time Tracker 选择一个更轻量的方向:
- 本地优先:历史记录保存在 VS Code 为本扩展提供的本地存储中。
- 零配置开始使用:安装后打开项目,开始写代码即可。
- 对“思考时间”更友好:盯着代码、分析问题、做算法题时,不会因为短时间没有键盘操作就立刻停止计时。
- 统计直接留在 VS Code 内:编码时长、项目统计、趋势、会话和番茄钟都可以直接查看。
- 无需账号和服务器:当前版本运行时不需要联网,也不依赖额外后台服务。
- 编辑代码、移动光标、打开文件等活动会被用于判断当前是否正在编码。
- 状态栏实时显示今日编码时长。
- 持续空闲后自动暂停,重新开始编码后自动恢复。
- VS Code 失焦后支持可配置的宽限时间,例如切到浏览器查 API 或资料。
默认的 adaptive 模式会统计VS Code 保持聚焦期间的活动间隔,并使用第 85 百分位(P85)估计你的正常思考间隔,同时受到可配置上下限约束。
也可以选择固定策略:
strict:3 分钟standard:10 分钟relaxed:30 分钟manual:自定义
这个机制主要用于解决一个简单问题:
写代码并不意味着必须一直敲键盘。阅读代码、思考算法和排查问题,同样可能属于有效编码时间。
统计面板目前包括:
- 今日 / 本周 / 累计编码时长
- 按项目统计时长
- 项目时长占比
- 近 14 天趋势
- 近 12 周日历热力图
- 今日编码会话
- 今日番茄完成次数
- Dashboard / Minimal 两套统计主题
编码会话会归属到当前活动 workspace。
支持 multi-root workspace;从项目 A 切换到项目 B 时,会拆分当前会话,避免后续时间继续错误记录到 A。
- 默认
25 + 5分钟,可配置专注与休息时长 - 支持开始、暂停、跳过、重置
- 可开启阶段结束通知
- 番茄钟与编码时长记录相互独立,不会决定某段编码时间是否计入统计
支持:
- 暂停 / 恢复编码计时
- 手动补记遗漏的编码时间
- 为补记会话选择项目、时间范围 / 时长和备注
当前正式版本通过 GitHub Releases 提供。
从 Latest Release 下载最新的 .vsix 文件,然后在 VS Code 中:
扩展 → ... → 从 VSIX 安装…
无需账号、服务器或额外后台服务,安装后即可开始记录。
Marketplace 发布正在准备中。当前请使用上面的 GitHub Release / VSIX 安装方式。
git clone https://github.com/yozi39/vscode-coding-time-tracker.git
cd vscode-coding-time-tracker
npm ci
npm test
npm run packagenpm run package 使用官方 @vscode/vsce 工具生成 VSIX。
- 在 VS Code 中打开任意项目或 workspace。
- 开始写代码,插件会自动记录。
- 状态栏可以查看今日编码时长和番茄钟状态。
- 打开 Coding Time 侧边栏,或在命令面板执行
Coding Time: 打开统计面板查看详细统计。
| 设置 | 默认值 | 说明 |
|---|---|---|
vscodeTime.idlePolicy.mode |
adaptive |
空闲策略:adaptive / strict / standard / relaxed / manual |
vscodeTime.idlePolicy.manualLimitMinutes |
10 |
手动模式下的聚焦空闲阈值(分钟) |
vscodeTime.idlePolicy.adaptiveMinMinutes |
3 |
自适应阈值下限 |
vscodeTime.idlePolicy.adaptiveMaxMinutes |
30 |
自适应阈值上限 |
vscodeTime.gracePeriodMinutes |
5 |
VS Code 失焦后的宽限时间;0 表示立即暂停 |
vscodeTime.pomodoro.focusMinutes |
25 |
番茄钟专注时间 |
vscodeTime.pomodoro.breakMinutes |
5 |
番茄钟休息时间 |
vscodeTime.pomodoro.notify |
true |
番茄阶段完成提醒 |
vscodeTime.statusBar.show |
true |
状态栏显示今日编码时长 |
vscodeTime.statusBar.showPomodoro |
true |
状态栏显示番茄钟 |
vscodeTime.stats.theme |
dashboard |
统计面板主题:dashboard / minimal |
| 命令 | 作用 |
|---|---|
Coding Time: 打开统计面板 |
打开统计面板 |
Coding Time: 暂停 / 恢复计时 |
暂停或恢复编码计时 |
Coding Time: 手动补记时间… |
手动补记编码会话 |
Coding Time: 开始 / 暂停番茄钟 |
开始或暂停番茄钟 |
Coding Time: 跳过当前番茄阶段 |
跳过当前阶段 |
Coding Time: 重置番茄钟 |
重置番茄钟 |
编码历史以本地 JSON 数据保存在 VS Code 为扩展提供的 globalStorageUri 中。
当前版本:
- 不发送遥测数据
- 运行时不发起网络请求
- 不需要账号
- 不需要独立的本地后台服务
正常扩展升级会继续使用同一个扩展存储目录。
不过卸载扩展不应该被当作数据备份方式。历史数据导入 / 导出已经列入路线图。
npm ci
npm run compile
npm test
npm run package测试覆盖包括:
- Tracker 状态机
- Idle Policy
- Adaptive Idle
- 跨日时间拆分
- 项目归属
- Pomodoro
- 数据聚合
- 多项计时正确性回归测试
每次 push 和 Pull Request 也会通过 GitHub Actions 自动运行 CI。
- 编码历史导入 / 导出(JSON / CSV)
- 中文 / English UI 国际化
- 按语言 / 文件统计编码时长
- 更多活跃时间可视化
Bug 和功能建议欢迎提交到 GitHub Issues。
Many coding-time tools rely on accounts, cloud dashboards, or external services.
Coding Time Tracker takes a smaller, local-first approach:
- Local-first — coding history stays in VS Code's local extension storage.
- Zero setup — install it, open a project, and start coding.
- Thinking-friendly — reading code, reasoning, and solving problems should not immediately look like inactivity.
- Inside VS Code — coding time, project statistics, trends, sessions, and Pomodoro are available directly in the editor.
- No account or server required — the current version does not require runtime network access or an external helper service.
- Uses editor activity such as editing, cursor movement, and opening files to detect active coding.
- Shows today's coding time in the status bar.
- Automatically pauses after sustained inactivity and resumes when coding continues.
- Supports a configurable grace period when VS Code loses focus.
The default adaptive policy learns from focused activity gaps and uses the 85th percentile (P85) as an estimate of your normal thinking interval, bounded by configurable minimum and maximum values.
Fixed policies are also available:
strict— 3 minutesstandard— 10 minutesrelaxed— 30 minutesmanual— choose your own threshold
The idea is simple:
Coding does not mean typing continuously. Reading code, reasoning about an algorithm, and debugging can still be part of productive coding time.
The dashboard currently includes:
- Today / this week / total coding time
- Per-project statistics
- Project time distribution
- 14-day activity trend
- 12-week calendar heatmap
- Today's coding sessions
- Daily Pomodoro count
- Dashboard and Minimal themes
Coding sessions are attributed to the active workspace.
Multi-root workspaces are supported. Switching from project A to project B splits the current session so later time is not silently attributed to the wrong project.
- Configurable focus and break durations (
25 + 5minutes by default) - Start, pause, skip, and reset
- Optional completion notifications
- Independent from coding-time tracking — Pomodoro state never decides whether coding time counts
You can:
- Pause / resume coding-time tracking
- Manually add a missed coding session
- Choose project, time range / duration, and an optional note
The current public release is distributed through GitHub Releases.
Download the latest .vsix from Latest Release, then in VS Code:
Extensions → ... → Install from VSIX...
No account, server, or separate background service is required. Install it and start coding.
Marketplace distribution is being prepared. For now, please use the GitHub Release / VSIX installation method above.
git clone https://github.com/yozi39/vscode-coding-time-tracker.git
cd vscode-coding-time-tracker
npm ci
npm test
npm run packagenpm run package uses the official @vscode/vsce package to build the VSIX.
- Open any project or workspace in VS Code.
- Start coding — tracking begins automatically.
- Check the status bar for today's coding time and Pomodoro state.
- Open the Coding Time sidebar or run
Coding Time: 打开统计面板from the Command Palette for detailed statistics.
| Setting | Default | Description |
|---|---|---|
vscodeTime.idlePolicy.mode |
adaptive |
Idle policy: adaptive, strict, standard, relaxed, or manual |
vscodeTime.idlePolicy.manualLimitMinutes |
10 |
Focused idle threshold for manual mode |
vscodeTime.idlePolicy.adaptiveMinMinutes |
3 |
Minimum adaptive threshold |
vscodeTime.idlePolicy.adaptiveMaxMinutes |
30 |
Maximum adaptive threshold |
vscodeTime.gracePeriodMinutes |
5 |
Grace period after VS Code loses focus; 0 pauses immediately |
vscodeTime.pomodoro.focusMinutes |
25 |
Pomodoro focus duration |
vscodeTime.pomodoro.breakMinutes |
5 |
Pomodoro break duration |
vscodeTime.pomodoro.notify |
true |
Show Pomodoro completion notifications |
vscodeTime.statusBar.show |
true |
Show today's coding time in the status bar |
vscodeTime.statusBar.showPomodoro |
true |
Show Pomodoro state in the status bar |
vscodeTime.stats.theme |
dashboard |
Statistics theme: dashboard or minimal |
| Command | Purpose |
|---|---|
Coding Time: 打开统计面板 |
Open the statistics dashboard |
Coding Time: 暂停 / 恢复计时 |
Pause or resume tracking |
Coding Time: 手动补记时间… |
Add a coding session manually |
Coding Time: 开始 / 暂停番茄钟 |
Start or pause Pomodoro |
Coding Time: 跳过当前番茄阶段 |
Skip the current Pomodoro phase |
Coding Time: 重置番茄钟 |
Reset Pomodoro |
Coding history is stored as local JSON data under the globalStorageUri provided by VS Code.
The current version:
- sends no telemetry;
- makes no runtime network requests;
- requires no account;
- requires no separate local helper service.
Normal extension upgrades continue to use the same extension storage.
Uninstalling the extension should not be treated as a backup strategy. History export / import is on the roadmap.
npm ci
npm run compile
npm test
npm run packageThe test suite covers:
- Tracker state machine
- Idle policy
- Adaptive idle detection
- Cross-day time splitting
- Project attribution
- Pomodoro
- Aggregation
- Regression cases for tracking correctness
Every push and pull request also runs CI through GitHub Actions.
- Coding-history export / import (JSON / CSV)
- Chinese / English UI localization
- Per-language and per-file coding statistics
- More activity visualizations
Bug reports and feature ideas are welcome in GitHub Issues.
Released under the MIT License.