Agent Skills
› benchflow-ai/skillsbench
› yaml-config
yaml-config
GitHub提供YAML配置文件的读写、解析及安全处理指南。强调使用safe_load防注入,支持参数合并与默认值回退,包含完整的错误处理逻辑,适用于车辆参数加载等场景。
Trigger Scenarios
读取或写入YAML配置文件
加载车辆参数
处理配置文件解析及错误
Install
npx skills add benchflow-ai/skillsbench --skill yaml-config -g -y
SKILL.md
Frontmatter
{
"name": "yaml-config",
"description": "Use this skill when reading or writing YAML configuration files, loading vehicle parameters, or handling config file parsing with proper error handling."
}
YAML Configuration Files
Reading YAML
Always use safe_load to prevent code execution vulnerabilities:
import yaml
with open('config.yaml', 'r') as f:
config = yaml.safe_load(f)
# Access nested values
value = config['section']['key']
Writing YAML
import yaml
data = {
'settings': {
'param1': 1.5,
'param2': 0.1
}
}
with open('output.yaml', 'w') as f:
yaml.dump(data, f, default_flow_style=False, sort_keys=False)
Options
default_flow_style=False: Use block style (readable)sort_keys=False: Preserve insertion orderallow_unicode=True: Support unicode characters
Error Handling
import yaml
try:
with open('config.yaml', 'r') as f:
config = yaml.safe_load(f)
except FileNotFoundError:
config = {} # Use defaults
except yaml.YAMLError as e:
print(f"YAML parse error: {e}")
config = {}
Optional Config Loading
import os
import yaml
def load_config(filepath, defaults=None):
"""Load config file, return defaults if missing."""
if defaults is None:
defaults = {}
if not os.path.exists(filepath):
return defaults
with open(filepath, 'r') as f:
loaded = yaml.safe_load(f) or {}
# Merge loaded values over defaults
result = defaults.copy()
result.update(loaded)
return result
Version History
- 9a1f4dd Current 2026-07-24 16:38


