mijia-control: Instructions file for Claude Code

CLAUDE.md

mijia-control CLAUDE.md is an instructions file for Claude Code from handsomejustin/mijia-control. It costs 1,151 tokens per session, scanned A, original, MIT.

Repository instructions for mijia-control, a Flask and MySQL application for controlling Xiaomi smart-home devices. It also includes a web interface, REST API, command-line tools, real-time communication, an AI-agent tool server, and a HomeKit bridge.

In plain words
What is it for?
Use them when changing the application, API, database models or migrations, smart-device integration, MCP server, or HomeKit bridge.
Why use it?
They give coding agents the project structure and the correct commands for building, testing, linting, database migrations, and running its different services.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md; mentions Claude Code.

This is handsomejustin/mijia-control's own configuration. It tells Claude Code how to work on mijia-control itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything mijia-control configures →

Reuse

Borrowing it

Nothing to install: this file belongs to handsomejustin/mijia-control. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/handsomejustin/mijia-control/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/handsomejustin/mijia-control

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mijia-control CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/handsomejustin/mijia-control/claude-md/github.svg)](https://agentmods.dev/instructions/handsomejustin/mijia-control/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/handsomejustin/mijia-control/claude-md"><img src="https://agentmods.dev/badge/instructions/handsomejustin/mijia-control/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mijia-control CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/handsomejustin/mijia-control/claude-md"><img src="https://agentmods.dev/badge/instructions/handsomejustin/mijia-control/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,151 This file is loaded in full into every session.
When invoked 1,151 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01151 $0.01151
Opus 5.5 $0.00460 $0.00460
Sonnet 5.5 $0.00230 $0.00230
Haiku 4.5 $0.00115 $0.00115

Measured 2mo ago against content hash 25c0c9ea23b9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

mijia-control CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 84 lines

How it starts

The opening of the file, as written. The whole thing — 84 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

米家智能设备控制系统 — Flask + MySQL 应用,提供 Web UI、REST API(Flasgger 文档在 /api/docs/)、CLI、SocketIO 实时通信、MCP Server(AI Agent 工具)和 HomeKit 桥接。

底层依赖 mijiaAPI 包(v3.0+)与小米云端通信,通过 app/utils/mijia_pool.py 的 MijiaAPIAdapter 适配(从 DB 中的 auth_data 直接初始化,无文件 I/O)。

Build, Test & Lint

python run.py                    # 启动开发服务器(SocketIO,端口 5000)
python -m mcp_server             # 启动 MCP Server(需 pip install -e ".[mcp]")
python -m app.homekit            # 启动 HomeKit Bridge(需 pip install -e ".[homekit]")
pytest -v                        # 运行测试
pytest tests/test_services/ -v   # 仅运行 service 层测试
ruff check .                     # Lint
ruff check --fix .               # Lint 自动修复
ruff format .                    # 格式化

Database

  • ORM: SQLAlchemy + Flask-Migrate(Alembic)
  • MySQL(pymysql),测试库为 mijia_test
  • 迁移:flask db migrate -m "描述" / flask db upgrade
  • 连接池配置:pool_recycle=3600, pool_pre_ping=True

Architecture

app/
├── __init__.py          # create_app() 工厂,注册扩展/蓝图/CLI/错误处理/安全头
├── extensions.py        # 单例扩展(db, migrate, jwt, csrf, limiter, socketio)
├── api/                 # REST API 蓝图(url_prefix=/api),JWT 认证
├── web/                 # Web UI 蓝图,Session+CSRF 认证
│   ├── routes.py        # 前端路由
│   ├── admin.py         # 管理后台
│   └── socketio.py      # SocketIO 事件
├── services/            # 业务逻辑层(不直接操作 HTTP request/response)
├── models/              # SQLAlchemy 模型
├── schemas/             # Marshmallow 序列化/校验
├── utils/               # MijiaAPIAdapter、统一响应格式、装饰器
├── cli/                 # Click CLI 命令
└── homekit/             # HomeKit Bridge(pyhap,设备映射 + 桥接启动)
mcp_server/              # MCP Server(FastMCP,通过 httpx 调用 Flask API)
config/                  # Flask 配置类(development/testing/production)
migrations/              # Alembic 迁移脚本
tests/                   # pytest 测试

Key Conventions

  • API 层只做参数校验和响应构造,业务逻辑放 services/
  • 统一响应使用 app/utils/response.py 的 success() / error() 辅助函数
  • API 认证:JWT(@jwt_required());Web 认证:Session + CSRF(Flask-Login + Flask-WTF)
  • 限流:Flask-Limiter,默认 200/day、50/hour
  • Ruff 配置:line-length=120,规则 E, F, W, I,目标 Python 3.9+

Read the full file on GitHub · 84 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 84 lines · 1,151 tokens per session scan A 25c0c9ea23b9

Subscribe to this mod's changes

mijia-control CLAUDE.md is an instructions file published in the GitHub repository handsomejustin/mijia-control (80 stars, last pushed 5mo ago), licensed MIT. It adds 1,151 tokens to every session, about $0.0046 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

mijia-control CLAUDE.md compared with instructions from other repositories

mijia-control CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
mijia-control CLAUDE.mdhandsomejustin/mijia-controlInstructions file805mo agoMITA1,151Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,516GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
vscode model-prompts.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA2,022GitHub Copilot