用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/personamanagmentlayer/pcl --skill finops-expert命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | finops-expert |
| version | 1.0.0 |
| description | Expert-level cloud financial operations, cost optimization, and cloud economics |
| category | professional |
| tags | ["finops","cloud-cost","optimization","cloud-economics","aws-cost"] |
| allowed-tools | ["Read","Write","Edit","Bash(*)"] |
Expert guidance for cloud financial operations, cost optimization, resource management, and cloud economics.
import boto3
from datetime import datetime, timedelta
from typing import Dict, List
import pandas as pd
class AWSCostAnalyzer:
"""Analyze AWS costs using Cost Explorer API"""
def __init__(self):
self.ce_client = boto3.client('ce')
def get_cost_and_usage(self, start_date: str, end_date: str,
granularity: str = 'DAILY',
metrics: List[str] = None) -> Dict:
"""Get cost and usage data"""
if metrics is None:
metrics = ['UnblendedCost', 'UsageQuantity']
response = self.ce_client.get_cost_and_usage(
TimePeriod={
'Start': start_date,
'End': end_date
},
Granularity=granularity,
Metrics=metrics,
GroupBy=[
{'Type': 'DIMENSION', 'Key': 'SERVICE'}
]
)
return response['ResultsByTime']
def get_top_services_by_cost(self, days: = , top_n: = ) -> pd.DataFrame:
end_date = datetime.now().strftime()
start_date = (datetime.now() - timedelta(days=days)).strftime()
results = .get_cost_and_usage(start_date, end_date, )
service_costs = {}
result results:
group result[]:
service = group[][]
cost = (group[][][])
service service_costs:
service_costs[service] += cost
:
service_costs[service] = cost
df = pd.DataFrame((service_costs.items()),
columns=[, ])
df.nlargest(top_n, )
() -> :
start_date = datetime.now().strftime()
end_date = (datetime.now() + timedelta(days=days_ahead)).strftime()
response = .ce_client.get_cost_forecast(
TimePeriod={
: start_date,
: end_date
},
Metric=,
Granularity=
)
{
: (response[][]),
: (response[][][])
}
() -> []:
response = .ce_client.get_rightsizing_recommendation(
Service=
)
recommendations = []
rec response[]:
recommendations.append({
: rec[][],
: rec[][],
: rec[][][][]
rec.get() ,
: (rec[][])
rec.get()
})
recommendations
:
():
.ec2_client = boto3.client()
.rds_client = boto3.client()
.s3_client = boto3.client()
() -> [, ]:
idle_resources = {
: [],
: [],
: [],
: []
}
instances = .ec2_client.describe_instances(
Filters=[{: , : []}]
)
reservation instances[]:
instance reservation[]:
idle_resources[].append({
: instance[],
: instance[],
: instance[][]
})
volumes = .ec2_client.describe_volumes(
Filters=[{: , : []}]
)
volume volumes[]:
idle_resources[].append({
: volume[],
: volume[],
: volume[]
})
addresses = .ec2_client.describe_addresses()
address addresses[]:
address:
idle_resources[].append({
: address[],
: address[]
})
idle_resources
() -> :
on_demand_hourly = ._get_on_demand_price(instance_type)
ri_hourly = on_demand_hourly *
hours_per_year = *
annual_on_demand = on_demand_hourly * hours_per_year * count
annual_ri = ri_hourly * hours_per_year * count
{
: instance_type,
: count,
: annual_on_demand,
: annual_ri,
: annual_on_demand - annual_ri,
: ((annual_on_demand - annual_ri) / annual_on_demand) *
}
() -> :
prices = {
: ,
: ,
: ,
: ,
:
}
prices.get(instance_type, )
class CostAllocation:
"""Manage cost allocation with tags"""
def __init__(self):
self.ec2_client = boto3.client('ec2')
self.ce_client = boto3.client('ce')
def define_tagging_strategy(self) -> Dict[str, List[str]]:
"""Define mandatory tags"""
return {
'environment': ['prod', 'staging', 'dev'],
'team': ['engineering', 'data', 'product'],
'cost_center': ['CC001', 'CC002', 'CC003'],
'project': ['project-a', 'project-b'],
'owner': ['email addresses']
}
def audit_resource_tags(self, resource_type: str = 'instance') -> List[Dict]:
"""Audit resources for missing tags"""
mandatory_tags = ['environment', 'team', 'cost_center']
untagged_resources = []
if resource_type == 'instance':
instances = .ec2_client.describe_instances()
reservation instances[]:
instance reservation[]:
tags = {tag[]: tag[]
tag instance.get(, [])}
missing_tags = [tag tag mandatory_tags
tag tags]
missing_tags:
untagged_resources.append({
: instance[],
: missing_tags
})
untagged_resources
() -> pd.DataFrame:
response = .ce_client.get_cost_and_usage(
TimePeriod={
: start_date,
: end_date
},
Granularity=,
Metrics=[],
GroupBy=[
{: , : tag_key}
]
)
costs = []
result response[]:
group result[]:
costs.append({
: group[][].split()[]
group[][] ,
: (group[][][])
})
pd.DataFrame(costs)
class BudgetManager:
"""Manage AWS budgets and alerts"""
def __init__(self):
self.budgets_client = boto3.client('budgets')
self.account_id = boto3.client('sts').get_caller_identity()['Account']
def create_monthly_budget(self, name: str, amount: float,
email: str) -> Dict:
"""Create monthly cost budget with alerts"""
budget = {
'BudgetName': name,
'BudgetLimit': {
'Amount': str(amount),
'Unit': 'USD'
},
'TimeUnit': 'MONTHLY',
'BudgetType': 'COST'
}
# Alert at 80% and 100%
notifications = [
{
'Notification': {
'NotificationType': 'ACTUAL',
'ComparisonOperator': 'GREATER_THAN',
'Threshold': 80,
'ThresholdType': 'PERCENTAGE'
},
'Subscribers': [{
'SubscriptionType': 'EMAIL',
'Address': email
}]
},
{
: {
: ,
: ,
: ,
:
},
: [{
: ,
: email
}]
}
]
response = .budgets_client.create_budget(
AccountId=.account_id,
Budget=budget,
NotificationsWithSubscribers=notifications
)
response
❌ No tagging strategy ❌ Ignoring rightsizing recommendations ❌ Not using Reserved Instances ❌ No budget alerts ❌ Keeping idle resources ❌ Manual cost tracking ❌ Siloed cost responsibility
基于 SOC 职业分类