大数跨境

不想写脚本、不想改 YAML?50条AI提示词包圆DevOps所有脏活累活(上)

不想写脚本、不想改 YAML?50条AI提示词包圆DevOps所有脏活累活(上) 云妙算
2025-07-29
2
导读:工位摸鱼神器,收藏级 AI 提示词大全

点击上方卡片,关注「CloudPilot AI」

5分钟,降低50%云成本


工具那天,我开始怀疑人生......


上个月,我干了一件近乎“自虐”的事:试着列出 DevOps 的所有工具。不是只有 Kubernetes、Jenkins、Terraform,还有各种日志系统、密钥管理器、CI/CD 平台、服务网格……


数到几十个我就放弃了。我们用工具来管理工具,再去配置其他工具。我发现自己越来越多时间花在摆弄工具上,而不是解决实际问题。


不知不觉间,DevOps 成了不停地写 YAML、调命令、复制粘贴的体力活。


直到那天下午,我被 Terraform 折磨得筋疲力尽,随手在浏览器的 AI 聊天框里打了一句: “写一个带版本控制和加密的 S3 Bucket 的 Terraform 模块。”


30 秒后,干净、可用的代码就出现在我面前。那一刻我意识到,也许我一直用错了方法在做 DevOps。


令人啼笑皆非的是,我们是做自动化的工程师——自动部署、自动测试、基础设施即代码样样精通,却唯独忽视了对日常重复性工作的自动化。


原因很简单:自动化基础设施是一项有挑战、有成就感的工作。而自动化文档、模板代码、重复性 Debug,反而让人觉得是“低级”劳动。


但 AI 不会这样看。你不会因为不会写正则或总是缩进错 YAML 而被“翻白眼”。AI 就像一个永不疲惫的资深工程师,随时准备帮你解决问题——而且从不厌烦。


01/

改变 DevOps 体验的 50 条提示词


以下是 50 个精心设计的 AI Prompt,专为解决那些让人头疼的 DevOps 日常事务。它们按常见痛点分类,经过实际场景测试,并附有适用示例。包括:


  • CI/CD 流水线构建、debug、性能优化提示词

  • 日志和监控创建、解析提示词

  • 技术文档提示词

  • Debug & 故障排查提示词

  • Bash 脚本创建提示词


你可以直接复制、修改、或根据实际需求调整。让 DevOps 中那些重复、枯燥的工作,也能实现自动化。


CI/CD 流水线提示词


1、生成 GitHub Actions Workflow


使用场景:启动新项目或从其他 CI 平台迁移


Create a GitHub Actions workflow for a Node.js application that:- Runs on push to main and pull requests- Tests on Node versions 16, 18, and 20- Runs lint, test, and build steps- Only deploys to production on main branch merges- Includes proper caching for node_modules- Sets up environment-specific secrets
为 Node.js 应用创建 GitHub Actions workflow:- 在推送到主系统和拉动请求时运行- 在 Node 16、18和20版本上测试- 运行 lint、test和build步骤- 只有在主分支合并时才部署到生产中- 包括适当的节点模块缓存- 设置特定环境的密钥


2、Debug 流水线故障


使用场景:流水线崩了,日志却像是出土文物,谁都看不懂。

I have a CI/CD pipeline failure. Here's the error log:[paste your error log]Help me:1. Identify the root cause2. Provide specific steps to fix it3. Suggest ways to prevent this error in the future4. Add appropriate error handling
CI/CD 流水线出现了问题,以下是错误日志:[粘贴错误日志]请帮助我:1. 定位根本原因2. 提供具体的步骤来修复它3. 提供一些建议,以避免未来重复出现4. 添加适当的错误处理


3、优化流水线性能


使用场景:本来只是个 5 分钟的构建,结果演变成了 30 分钟的煎熬。

Analyze this pipeline configuration and suggest optimizations:[paste your pipeline config]Focus on:- Parallel job execution- Caching strategies- Unnecessary steps- Build time reduction- Resource efficiency
分析该流水线的配置,并建议优化:[粘贴你的流水线配置]聚焦于:- 并行作业执行- 缓存策略- 不必要的步骤- 构建时间减少- 资源利用率


4、创建多环境流水线


使用场景:设置合理的测试/staging/生产环境 workflow

Design a CI/CD pipeline strategy for deploying to:- Development (auto-deploy on feature branch push)- Staging (auto-deploy on main branch merge)- Production (manual approval required)Include:- Environment-specific configurations- Rollback strategies- Security considerations- Approval workflows
设计一个 CI/CD 流水线策略以部署到:- 开发环境(在功能分支推送时自动部署)- Staging 环境(在主分支合并时自动部署)- 生产环境(需要手动批准)包含:- 特定环境的配置- 回滚策略- 安全策略- 审批流程


5、生产流水线文档


使用场景:当团队一直问:“这条流水线怎么跑的?”

Create comprehensive documentation for this CI/CD pipeline:[paste your pipeline configuration]Include:- Overview and purpose- Trigger conditions- Step-by-step breakdown- Environment variables needed- Troubleshooting guide- How to modify for new requirements
为该 CI/CD 流水线创建一份详细的文档[粘贴你的流水线配置]包含:- 概览和目的- 触发条件- 步骤拆解- 所需的环境变量- 故障排查指南- 如何为新的需求进行修改


日志和监控提示词


6、解析复杂日志文件


使用场景:当 grep 无法满足您的需求,而您又需要提取有意义的数据时。

Help me parse this log file to extract:[specify what you need: error patterns, performance metrics, user actions, etc.]Log sample:[paste a representative sample of your logs]Provide:1. Command-line tools (awk, sed, jq) for extraction2. Regex patterns for matching3. One-liner commands for common queries4. Script to automate the parsing
帮我解析这个日志文件,以便提取:[指定你的需求:错误范式、性能指标、用户行为等等]日志示例:[粘贴一个具有代表性的日志示例]提供:1. 用于提取的命令行工具(aws、sed、jq)2. 用于匹配的正则模式3. 用于常见查询的一行命令4. 自动化解析的脚本


7、创建日志分析脚本


使用场景:适用于耗费时间的重复性日志分析任务。

Create a script that analyzes [application/service] logs to:- Count error types and frequency- Identify performance bottlenecks- Extract timing information- Generate summary reports- Alert on specific patternsInput format: [describe your log format]Output: Human-readable summary + CSV for further analysis
创建脚本来分析[应用/服务]的日志:- 了解错误类型和发生频率- 查找性能瓶颈- 提取时间信息- 生成总结报告- 特定模式的告警输入格式:[描述你的日志格式】输出:人类可读的总结+ CSV,以供进一步分析


8、设置监控查询


使用场景:从0开始写 Prometheus、Grafana 或 CloudWatch 的查询

Create monitoring queries for [Prometheus/CloudWatch/Grafana] to track:- [specific metric you want to monitor]- Alert when [condition]- Dashboard visualization showing [what you want to see]Context: [describe your application/infrastructure]Current metrics available: [list existing metrics if known]
[Prometheus/CloudWatch/Grafana]创建监控查询以跟踪:[你想要监控的特定指标]- 当满足[某个条件]时,触发告警- 可视化面板,展示[你想要看到的指标]上下文:[描述你的应用/基础设施]当前可用指标:[列出已有指标]


9、设计告警策略


使用场景:当你被误报搞得焦头烂额,真出事时却一点动静都没有

Design an alerting strategy for [describe your system] that:- Minimizes false positives- Catches real issues before users notice- Provides actionable information- Escalates appropriately- Includes runbook linksCurrent pain points: [describe what's not working]Team size: [number] peopleOn-call rotation: [describe your setup]
为[在此处描述的系统]设计告警策略:- 最小化误报- 在用户发现之前捕捉到真正的问题- 提供可执行的排查信息- 具备合理的升级机制- 告警中附带运行手册(Runbook)链接当前痛点:[请描述目前存在的问题]团队规模:[人数]人值班轮换机制:[请描述你的轮班安排]


10、排查监控问题


使用场景:当你的监控工具对你撒谎时

My monitoring is showing [describe the issue], but [describe what's actually happening].Help me:1. Debug why the metrics don't match reality2. Fix the monitoring configuration3. Identify blind spots in current monitoring4. Add missing metrics/alerts5. Validate the monitoring is working correctlyMonitoring stack: [list your tools]
我的监控显示[描述问题],但[描述实际发生的情况]。请帮助我:1. debug 为什么指标与现实情况不一致2. 修复监控配置3. 在当前监控中识别盲点4. 添加遗漏的指标/告警5. 验证监控是否正确工作监控栈:列出你的工具


技术文档提示词


11、生成 API 文档


使用场景:当你不仅要写 API 文档,还得让它真的有人看、有人能用。

Create comprehensive API documentation for:[paste your API specification/swagger/code]Include:- Clear endpoint descriptions- Request/response examples- Authentication requirements- Error codes and handling- Rate limiting information- SDK examples in [preferred languages]- Common use cases and workflows
创建完整的 API 文档:[粘贴你的 API 规范/swagger/代码]包含:- 清晰的 endpoint 描述- 请求/响应 示例- 身份验证要求- 错误代码和处理- 速率限制信息- SDK示例- 常见用例和工作流


12、编写运行手册文档


使用场景:凌晨 2 点系统出问题,而你完全不记得该怎么修的时候。

Create a troubleshooting runbook for [service/application] covering:- Common failure scenarios: [list them]- Step-by-step recovery procedures- Required access/permissions- Escalation contacts- How to communicate with stakeholders- Post-incident cleanup stepsMake it usable by junior engineers during high-stress situations.
为[服务/应用]创建一个故障排查的运行手册,包括以下内容:- 常见故障场景:[列出来]- 逐步恢复流程- 所需的访问/权限- 提级联系人- 如何与相关方沟通- 事后清理步骤让初级工程师在高压力情况下也能使用。


13、创建架构文档


使用场景:当你需要为团队新成员解释系统架构时

Document this system architecture:[describe your system, paste diagrams, or provide code]Include:- High-level overview- Component responsibilities- Data flow diagrams- Integration points- Scalability considerations- Security boundaries- Deployment topology- Decision rationale for key choices
记录该系统架构:[描述你的系统、粘贴架构图或提供代]包括:- 高层级的总览- 组件功能- 数据流图示- 集成点- 可扩展性的考量- 安全边界- 部署拓扑- 关键选择的决策依据


14、写安装指南


使用场景: 设置应用程序时不需要计算机科学学位。

Create step-by-step installation documentation for [your application/service] that includes:- Prerequisites and system requirements- Installation methods (Docker, package manager, source)- Configuration options- Verification steps- Common troubleshooting- Upgrade procedures- Uninstall instructionsTarget audience: [describe skill level]
为[应用/服务]创建一个逐步安装文档:- 前期准备和系统要求- 安装方法(Docker、package管理器、二进制)- 配置选项- 验证步骤- 常见故障排查- 升级流程- 卸载步骤面向受众:[描述所需技能等级]


15、生成 README 文件


使用场景:每当你意识到“TODO: Add documentation”已经躺在仓库里好几个月

Create a comprehensive README for this project:[paste repository information, code samples, or describe the project]Include:- Clear project description and purpose- Quick start guide- Installation instructions- Usage examples- Configuration options- Contributing guidelines- License information- Badges for build status, coverage, etc.
为这个项目创建一个完整的 README:[粘贴仓库信息、代码示例,或描述这个项目]包括:- 清晰的项目描述,以及这个项目解决了什么问题- 快速启动指南- 安装指南- 用例展示- 配置选项- 贡献手册- 许可证信息- 构建状态徽章


Debug & 故障排查提示词


16、Debug 应用错误


使用场景:当错误提示形同虚设,看了也不知道哪里出了问题。

I'm getting this error in [application/service]:[paste full error message and stack trace]Context:- What I was trying to do: [describe the action]- Environment: [production/staging/local]- Recent changes: [any deployments, config changes, etc.]- Additional symptoms: [other weird behavior]Help me:1. Understand what this error means2. Find the root cause3. Fix it step by step4. Prevent it from happening again
我在 [应用/服务] 中遇到了这个错误:[粘贴完整错误信息和追踪信息]上下文:- 我正在尝试做的:[描述已经做的操作]- 环境:[生产/staging/本地]- 近期变更:[任意部署、配置变更等]- 其他表现:[其他奇怪的现象]帮助我:1. 理解这个错误是什么意思2. 寻找根本原因3. 逐步修复4. 防止它再次发生


17、性能故障排查


使用场景:“昨天明明响应还很快”

My [application/database/service] performance has degraded. Help me investigate:Symptoms:- [describe what's slow]- Started around: [timeframe]- Affects: [users/operations/etc.]Current metrics:- [paste relevant performance data]System info:- [infrastructure details]- [recent changes]Provide a systematic troubleshooting approach with specific commands to run.
我的[应用/服务]性能降级了。帮我调查:现象:[描述什么变慢了]- 大约从何时开始:[时限]- 影响:[用户/操作等等]当前指标:[粘贴相关的性能数据]系统信息:[基础设施细节][近期变更]提供一个系统的故障排查方法以及需要运行的命令


18、数据库查询优化


使用场景:当你的数据库查询比早高峰堵车还要卡

Optimize this database query:[paste your SQL query]Current performance:- Execution time: [time]- Rows examined: [number]- Database: [MySQL/PostgreSQL/etc.]Table schemas:[paste relevant table structures]Provide:1. Optimized query2. Index recommendations3. Explanation of improvements4. Alternative approaches
优化数据库查询:[粘贴你的 SQL 查询]当前性能:- 执行时间:[时间]- 扫描行数:数量- 数据库类型:[MySQL/PostgreSQL等]表结构信息:[粘贴相关表结构]请提供:1. 优化后的查询语句2. 索引优化建议3. 优化点说明4. 可选的替代方案


19、容器故障排查


使用场景:当 Docker 容器开始各种花样作死。

My container is [crashing/not starting/behaving weird]:Dockerfile:[paste Dockerfile]Error logs:[paste container logs]Environment:- Docker version: [version]- Host OS: [OS]- Kubernetes version: [if applicable]Help me:1. Identify the issue2. Fix the container configuration3. Add proper health checks4. Optimize the image
我的容器出现了【崩溃/无法启动/行为异常】:Dockerfile:[粘贴Dockerfile内容] 错误日志:[粘贴容器日志]运行环境:Docker 版本:[版本号]主机操作系统:[操作系统]Kubernetes 版本(如适用):[版本号]请帮我:1. 诊断问题原因2. 修复容器配置3. 添加合理的健康检查4. 优化镜像体积与性能


20、网络连通性问题


使用场景:服务不互通,只好化身“网络福尔摩斯”。

I have a network connectivity issue:- Service A ([details]) can't reach Service B ([details])- Error: [paste error message]- Network setup: [describe topology]- Security groups/firewalls: [describe rules]Help me:1. Debug the connection step by step2. Identify where the traffic is blocked3. Provide specific commands to test connectivity4. Fix the networking configuration
我遇到了网络连通性问题:服务 A [详情]无法访问服务 B[详情]错误信息:[粘贴错误]网络拓扑:[描述网络结构]安全组/防火墙规则:[描述相关规则]请帮我:1. 逐步排查连接问题2. 定位流量阻断点3. 提供具体的连通性测试命令4. 修复网络配置


Bash 脚本提示词


21、生成开发脚本


使用场景:当您需要一套绝对可靠的自动化部署方案。

Create a bash deployment script for [describe your application] that:- Pulls latest code from git- Builds the application- Runs tests before deploying- Creates backups before deployment- Deploys with zero downtime- Verifies deployment success- Rolls back on failure- Sends notificationsInclude proper error handling and logging.
为 [请描述你的应用] 编写一个 Bash 部署脚本,要求实现以下功能:- 从 Git 拉取最新代码- 构建应用- 部署前运行测试- 部署前创建备份- 实现零停机部署- 验证部署成功- 部署失败时自动回滚- 发送通知请包含完善的错误处理和日志记录。


22、系统维护脚本


使用场景:当你总是忘记做一些日常琐碎的工作

Create a system maintenance script that:- Cleans up old log files (keep last 30 days)- Removes unused Docker images and containers- Updates packages securely- Checks disk space and alerts if >80% full- Backs up critical configurations- Generates maintenance reportMake it safe to run automatically via cron.
编写一个系统维护脚本,要求实现以下功能:- 清理超过30天的旧日志文件- 删除未使用的 Docker 镜像和容器- 安全更新系统软件包- 检查磁盘空间,超过80%时发出警报- 备份关键配置文件- 生成维护报告请确保脚本安全可靠,适合通过 cron 定时自动执行。


23、日志轮换和清理


使用场景:当你的磁盘空间比周末还快消失的时候。

Create a log management script that:- Rotates logs for [specify your applications]- Compresses old logs- Deletes logs older than [timeframe]- Handles multiple log formats- Preserves logs during active debugging- Sends alerts when cleanup failsApplications: [list your apps and their log locations]
编写一个日志管理脚本,要求实现以下功能:- 对[请指定你的应用]的日志进行轮转- 压缩旧日志文件- 删除超过[时间范围]的日志- 支持多种日志格式- 调试期间保留日志不被清理- 清理失败时发送告警应用列表及日志路径:[列出你的应用及对应日志位置]


24、备份和恢复脚本


使用场景:备份就像保险,平时很无聊,但一旦需要则很致命

Create backup and restore scripts for:- Database: [type and connection details]- Application files: [locations]- Configuration files: [locations]- User data: [locations]Requirements:- Encrypted backups- Remote storage (S3/GCS/etc.)- Retention policy: [specify]- Verification that backups work- Easy restore process- Progress monitoring
为以下组件创建备份和恢复脚本:- 数据库:[输入连接细节]- 应用文件:[位置]- 配置文件:[位置]- 用户数据:[位置]要求:- 加密备份- 远程存储(S3\GCS等)- 保留策略:[请指定]- 验证备份是否正常- 简单的恢复流程- 监控进程


25、健康检查脚本


使用场景: 主动监控,切实预防问题。

Create a comprehensive health check script for [your infrastructure] that:- Tests all critical services- Verifies database connections- Checks API endpoints- Monitors resource usage- Validates SSL certificates- Ensures backup processes are working- Generates readable status reportsExit codes for integration with monitoring systems.
为[你的基础设施]编写一份全面的健康检查脚本,要求包括:- 测试所有关键服务的可用性- 验证数据库连接状态- 检查 API 接口响应- 监控资源使用情况- 校验 SSL 证书有效性- 确保备份流程正常运行- 生成可读的状态报告脚本需返回合适的退出码,以便与监控系统集成。


02/

总 结


本文为系列文章的上篇,介绍了如何自动化 CI/CD 流水线、日志与系统健康检查、技术文档等日常开发任务。下篇将带你了解如何借助 AI 自动生成 Kubernetes YAML 文件,辅助面试准备,以及制定职业发展路径。


欢迎关注「CloudPilot AI」,及时获取内容更新!


推荐阅读

Karpenter 实现多云支持最后一块拼图:GCP Provider 预览版发布

免费用爆AWS!初创和独立开发者必看的0元架构搭建指南

云成本动辄上万?这家技术团队用三步搞定降本 + 扩容

公司介绍

CloudPilot AI 是一家全球领先的 Karpenter 托管云服务提供商,致力于通过智能化、自动化的云资源调度和编排技术,帮助企业最大化云资源利用率。我们秉持“让客户在云中花费的每一分钱都物超所值”的使命,为客户提升10倍的资源效率,同时将云成本降低50%以上。


目前,开源K8s弹性伸缩器 Karpenter 已为全球超500家知名企业在生产环境中提供服务,包括阿迪达斯、Anthropic、Slack、Figma等。CloudPilot AI 已为数百家全球顶尖科技公司提供服务,累计为客户节省超过千万美金,平均节省67%。 选择CloudPilot AI,让每一笔支出都更智慧。


免费试用,2步5分钟,降低50%云成本:

cloudpilot.ai

【声明】内容源于网络
0
0
云妙算
让您在云中花费的每一分钱都物超所值
内容 0
粉丝 0
云妙算 让您在云中花费的每一分钱都物超所值
总阅读0
粉丝0
内容0