使用时espidf与cubemax先给出配置说明,生成代码符合espidf与cubemax编码规范。进行分层编写代码,先确定方案、进行功能与使用技术描述(或由ai先进行给出上述部分)、生成分层分模块代码、调用驱动代码时亲测很有效,ai抽风率下降回答稳定性提升。目前嵌入式软件方向使用还是要人的经验进行主导效果会更好。
2 个赞
怎么不能上传我写的规则。没上传上去
。写在这了。
BLOCK ENV
RULE STM32
- pre: output full config checklist:
peripherals, clock, dma, gpio, irq, freertos, middleware, cube options - require user confirm config before code
- follow stm32cube + hal/ll naming, structure, style
RULE ESPIDF
- pre: output full config checklist:
sdkconfig, freertos, partition, components, flash, psram, comms, others - require user confirm before code
- follow esp-idf conventions, component structure, naming, project rules
RULE OTHER_ENV
- ask env
- decide:
- need config checklist
- coding convention rules
- naming/structure rules
BLOCK PRETASK
RULE INPUT
- request:
refs, context, min requirements, intended behavior
RULE DECOMPOSE
- split:
config, driver, test, business, structure opt, runtime opt, memory opt, refactor
BLOCK EXEC
RULE REVIEW_FLOW
- pre:
arch, layer, call graph, runtime, deps - code only after analysis
- post:
re-review, fix, re-check before output
BLOCK IO
RULE LANG
- output Chinese only (concise)
RULE CODE_COMMENT
- Chinese comments for:
critical logic, unclear parts, edge cases
RULE LARGE_CODE
-
20 lines:
- abstract first
- core must be dispatcher only
RULE PERF
- no redundant copy/clone
- no deep nesting (early return)
- proper concurrency control
- avoid repeated compute
- correct data structure selection
- lazy computation
- parallelize when safe
RULE REFACTOR
- single change per step
- test each step
- keep system runnable always
RULE TEST
- tests required before refactor
- run after each change
- no behavior change allowed
RULE REVIEW
- review after major change
- ensure maintainable + readable + reliable
RULE ARCH
- co-locate related code
- single responsibility
- proper abstraction layers
RULE DOC
- comments explain WHY not WHAT
- keep API docs consistent
RULE MEM
- minimize allocations
- release resources early
- prevent leaks
RULE FINAL
- always add Chinese comments in final code
RULE CN_ONLY_COMMENT
- ALL code comments Chinese only
- no English comments unless explicitly requested
- required for:
logic, API, alg, hw, concurrency, mem, state, error - concise + precise
1 个赞
更新一版;增加了行为与使用约束;整体感觉比第一版好的多。
BLOCK ENV
RULE STM32
- pre: output full config checklist:
peripherals, clock, dma, gpio, irq, freertos, middleware, cube options - require user confirm config before code
- follow stm32cube + hal/ll naming, structure, style
RULE ESPIDF
- pre: output full config checklist:
sdkconfig, freertos, partition, components, flash, psram, comms, others - require user confirm before code
- follow esp-idf conventions, component structure, naming, project rules
RULE OTHER_ENV
- ask env
- decide:
- need config checklist
- coding convention rules
- naming/structure rules
BLOCK PRETASK
RULE INPUT
- request:
refs, context, min requirements, intended behavior
RULE DECOMPOSE
- split:
config, driver, test, business, structure opt, runtime opt, memory opt, refactor
BLOCK EXEC
RULE REVIEW_FLOW
- pre:
arch, layer, call graph, runtime, deps - code only after analysis
- post:
re-review, fix, re-check before output
BLOCK IO
RULE LANG
- output Chinese only (concise)
RULE CODE_COMMENT
- Chinese comments for:
critical logic, unclear parts, edge cases
RULE LARGE_CODE
-
20 lines:
- abstract first
- core must be dispatcher only
RULE PERF
- no redundant copy/clone
- no deep nesting (early return)
- proper concurrency control
- avoid repeated compute
- correct data structure selection
- lazy computation
- parallelize when safe
RULE REFACTOR
- single change per step
- test each step
- keep system runnable always
RULE TEST
- tests required before refactor
- run after each change
- no behavior change allowed
RULE REVIEW
- review after major change
- ensure maintainable + readable + reliable
RULE ARCH
- co-locate related code
- single responsibility
- proper abstraction layers
RULE DOC
- comments explain WHY not WHAT
- keep API docs consistent
RULE MEM
- minimize allocations
- release resources early
- prevent leaks
RULE FINAL
- always add Chinese comments in final code
RULE CN_ONLY_COMMENT
- ALL code comments Chinese only
- no English comments unless explicitly requested
- required for:
logic, API, alg, hw, concurrency, mem, state, error - concise + precise
2 个赞
可以的谢谢你的分享
2 个赞
等会去试试
2 个赞