← Back to Skills Marketplace
534422530

健康追踪

by 534422530 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
49
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install laosi-health
Description
健康追踪技能 - 追踪饮水、睡眠、步数等健康数据,JSON存储。
README (SKILL.md)

Health Tracker - 健康追踪

激活词: 健康追踪 / 记录饮水 / 睡眠追踪

功能

  • 饮水记录
  • 睡眠追踪
  • 步数记录
  • 体重追踪
  • 数据统计

数据存储

{
  "water": [
    {"time": "2026-04-28T08:00:00", "amount": 250}
  ],
  "sleep": [
    {"date": "2026-04-27", "start": "23:00", "end": "07:00", "hours": 8}
  ],
  "steps": [
    {"date": "2026-04-28", "count": 8000}
  ]
}

Python实现

import json
from datetime import datetime
from pathlib import Path

class HealthTracker:
    def __init__(self, data_file: str = "health_data.json"):
        self.data_file = data_file
        self.data = self._load()
    
    def _load(self) -> dict:
        if Path(self.data_file).exists():
            with open(self.data_file, 'r') as f:
                return json.load(f)
        return {'water': [], 'sleep': [], 'steps': []}
    
    def _save(self):
        with open(self.data_file, 'w') as f:
            json.dump(self.data, f, indent=2)
    
    def log_water(self, amount: int):
        self.data['water'].append({
            'time': datetime.now().isoformat(),
            'amount': amount
        })
        self._save()
    
    def log_sleep(self, start: str, end: str):
        hours = self._calc_hours(start, end)
        self.data['sleep'].append({
            'date': datetime.now().date().isoformat(),
            'start': start,
            'end': end,
            'hours': hours
        })
        self._save()
    
    def log_steps(self, count: int):
        today = datetime.now().date().isoformat()
        # ���新今日数据
        for entry in self.data['steps']:
            if entry['date'] == today:
                entry['count'] = count
                break
        else:
            self.data['steps'].append({'date': today, 'count': count})
        self._save()
    
    def get_stats(self) -> dict:
        # 今日饮水
        today = datetime.now().date().isoformat()
        water_today = sum(e['amount'] for e in self.data['water'] 
                         if e['time'].startswith(today))
        
        # 平均睡眠
        if self.data['sleep']:
            avg_sleep = sum(e['hours'] for e in self.data['sleep']) / len(self.data['sleep'])
        else:
            avg_sleep = 0
        
        return {
            'water_today': water_today,
            'water_goal': 2000,
            'avg_sleep': avg_sleep,
            'steps_today': self._get_steps_today(),
        }
    
    def _calc_hours(self, start: str, end: str) -> float:
        start_h, start_m = map(int, start.split(':'))
        end_h, end_m = map(int, end.split(':'))
        hours = end_h - start_h
        if end_h \x3C start_h:
            hours += 24
        return hours - start_m/60 + end_m/60
    
    def _get_steps_today(self) -> int:
        today = datetime.now().date().isoformat()
        for entry in self.data['steps']:
            if entry['date'] == today:
                return entry['count']
        return 0

使用命令

tracker = HealthTracker()

# 记录饮水
tracker.log_water(250)  # 250ml

# 记录睡眠
tracker.log_sleep("23:00", "07:00")

# 记录步数
tracker.log_steps(8000)

# 获取统计
stats = tracker.get_stats()
print(f"今日饮水: {stats['water_today']}ml / {stats['water_goal']}ml")
print(f"平均睡眠: {stats['avg_sleep']:.1f}小时")

输出格式

## 健康数据

### 今日
- 饮水: 1500ml / 2000ml (75%)
- 步数: 8000步
- 睡眠: 7.5小时 (平均)

### 周报
- 平均饮水: 1800ml/天
- 平均睡眠: 7.2小时/天
- 总步数: 56,000步
Usage Guidance
This skill appears to be a small, local health tracker that saves data to a JSON file (health_data.json) in the agent's working directory. It does not ask for credentials or perform network I/O. Consider where the agent will run: if the agent runs on a shared or cloud-hosted environment, the JSON file will be stored there and could contain personal health information, so you may want to restrict file permissions, move storage to a location you control, or add encryption if necessary. If you need remote sync or backups, add explicit, trusted integrations rather than relying on this simple local storage.
Capability Analysis
Type: OpenClaw Skill Name: laosi-health Version: 1.0.0 The health-tracker skill bundle is a straightforward utility for logging and retrieving personal health data (water, sleep, steps) stored in a local JSON file. The Python implementation in SKILL.md is clean, lacks any network or shell execution capabilities, and strictly adheres to its stated purpose without any indicators of malicious intent or prompt injection.
Capability Assessment
Purpose & Capability
Name and description (track water, sleep, steps, stats) match the provided Python implementation and the declared JSON storage; no unrelated capabilities or external services are requested.
Instruction Scope
SKILL.md contains only local operations (create/read/write a local health_data.json and compute simple stats). It does not instruct reading unrelated system files, accessing environment variables, or sending data externally.
Install Mechanism
Instruction-only skill with no install spec and no code files executed by the platform. The provided example Python code is simple and local; there are no download URLs or package installs.
Credentials
The skill declares no environment variables, credentials, or config paths. The storage is a single local file (default health_data.json), which is appropriate for the stated functionality.
Persistence & Privilege
The skill is not forced-always, does not request elevated privileges, and does not modify other skills or system settings. It only writes its own data file in the current working directory.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install laosi-health
  3. After installation, invoke the skill by name or use /laosi-health
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
追踪饮水、睡眠、步数等健康数据
Metadata
Slug laosi-health
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is 健康追踪?

健康追踪技能 - 追踪饮水、睡眠、步数等健康数据,JSON存储。 It is an AI Agent Skill for Claude Code / OpenClaw, with 49 downloads so far.

How do I install 健康追踪?

Run "/install laosi-health" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is 健康追踪 free?

Yes, 健康追踪 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does 健康追踪 support?

健康追踪 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created 健康追踪?

It is built and maintained by 534422530 (@534422530); the current version is v1.0.0.

💬 Comments