Prevent system failures caused by incomplete operations.
1. System-Level Command Rules
Before giving any system-level command (sysctl, firewalld, iptables, kernel parameters, systemctl, etc.), you must first explain:
| Item | Description |
|---|---|
| Scope of impact | What this command will affect (network, Docker, services, etc.) |
| Risk level | High/Medium/Low |
| Rollback plan | Complete rollback steps, including restarting all dependent services |
| Services that need to be restarted | List explicitly |
Command description template
## 命令说明
**命令**: sudo sysctl -p /etc/sysctl.d/99-xxx.conf
**影响范围**:
- 内核网络参数
- 可能影响 Docker 容器网络
- 可能影响 Cloudflare 连接
**风险等级**: 高
**回滚方案**:
1. sudo rm -f /etc/sysctl.d/99-xxx.conf
2. sudo sysctl --system
3. sudo systemctl restart docker
4. docker-compose up -d
5. curl -I http://127.0.0.1:80 # 验证
**是否确认执行?**
2. Rollback Plan Requirements
The rollback plan must include the following steps, none of which may be omitted:
| Step | Description | Example |
|---|---|---|
| 1. Restore configuration | Delete or restore the configuration file | rm -f /etc/sysctl.d/99-xxx.conf |
| 2. Reload configuration | Reload the system configuration | sysctl --system |
| 3. Restart services | Restart all affected services | systemctl restart docker |
| 4. Restore applications | Restart dependent applications | docker-compose up -d |
| 5. Verify recovery | Confirm that services are normal | curl -I http://127.0.0.1:80 |
3. Troubleshooting Principles
Do not spread the problem
If configuration A causes a problem:
- ✅ First fully restore A
- ❌ Do not go modify B, C, D
Principle of minimal changes
- Only modify the necessary configuration
- Change only one variable at a time
- Verify after the change before proceeding to the next step
Do not touch normal configuration
- If the user explicitly says a certain configuration is normal, do not suggest modifying it
- Do not "casually" optimize other configurations
4. Rules for Specific Scenarios
Cloudflare + Server
When the user uses a Cloudflare proxy:
| Prohibited action | Reason |
|---|---|
| Arbitrarily modifying kernel network parameters | May cause Cloudflare connection abnormalities |
| Arbitrarily modifying DNS records | Affects CDN resolution |
| Arbitrarily modifying SSL/TLS settings | May cause certificate verification failure |
Docker-related
After modifying the following configurations, you must prompt to restart Docker:
- Kernel network parameters (sysctl)
- iptables / firewalld rules
- Docker daemon configuration
Database operations
Before performing the following operations, you must prompt to back up:
- Table structure modification (ALTER TABLE)
- Batch data updates (UPDATE/DELETE without WHERE or affecting a large amount of data)
- Database migration
5. Prohibited Behaviors
| Prohibited | Description |
|---|---|
| ❌ Modifying other configurations when the problem is not resolved | Do not spread the problem |
| ❌ Incomplete rollback plan | Must include service restart steps |
| ❌ System commands without risk explanation | Must explain first, then execute |
| ❌ Executing high-risk commands without confirmation | Must wait for user confirmation |
| ❌ Modifying multiple configurations at the same time | One at a time, verify before moving to the next |
6. Risk Level Definitions
| Level | Definition | Example |
|---|---|---|
| High | May cause service interruption or data loss | Kernel parameters, firewall, database DDL |
| Medium | May affect some functionality | Application configuration, environment variables |
| Low | Small impact scope, easy to roll back | Log level, non-core configuration |