agentleFS
SmailGSmailG/plc-programming/skills/develop/SKILL.md

develop

Skill0 starsChanged 37 days agoMITView on GitHub

End-to-end workflow for designing, writing, extending and advising on PLC programs: from control narrative and I/O list to architecture (ISA-88 control modules, state machines, tasks), to code in the target dialect (IEC ST/LD/FBD/SFC, Siemens SCL/TIA, Schneider Machine Expert/Control Expert, CODESYS, TwinCAT, Logix, IEC 61499), to validation, self-review and a test plan. Use whenever the user wants a new PLC program, function block, sequence or interlock logic, wants existing PLC code changed or extended, or asks how to structure or improve an automation program — even if they only describe the machine or process and never say "PLC".

28 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use scope, sync and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • YuriNachosSkill

    scope

    Configure claude-scope status line widgets for Claude Code. Use when user wants to customize widgets, change theme, reorder elements, or modify display style.

    Also in 6 projects that use this

  • MicrosoftSkill

    sync

    Sync the current session branch with its upstream branch, or publish the current session branch to a remote. Use when the user asks to sync a branch, pull latest changes, rebase onto upstream, push current branch, publish branch, or set upstream.

    Also in 6 projects that use this

  • nicolasestremSkill

    document

    Create focused documentation for specific components or features

    Also in 5 projects that use this

  • kt057Skill

    check

    lint, typecheck, test を一括実行して結果をサマリーする

    Also in 5 projects that use this

  • Harut8Skill

    architect

    Also in 9 projects that use this

  • Microsoft AzureSkill

    test

    Also in 6 projects that use this

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 6 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 23 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Write in the target dialect.

    line 69
  2. Distinctive:

    Call every timer, edge and counter instance exactly once per scan, unconditionally, and gate its input instead of its call.

    line 73
  3. Distinctive:

    Write every output once (no double coils).

    line 75
  4. Very specific:

    Use no blocking loops (no waiting inside WHILE).

    line 79
  5. Distinctive:

    Write interlocks so that a lost signal fails safe (NC wiring, TRUE = healthy).

    line 80
  6. Very specific:

    Run python3 ${CLAUDE_PLUGIN_ROOT}/scripts/plc_validate.py <files>.

    line 86
  7. Distinctive:

    Write a test plan: a table of preconditions, stimulus and expected outputs/states, covering normal flow, every interlock, every timeout and …

    line 91
  8. Very specific:

    Minimal diff, same style: Do not reformat. Preserve IDs: TwinCAT Id GUIDs, SimaticML ID/UId, and L5X names.

    line 103
  9. Distinctive:

    Keep a rollback: the previous export and the exact version running on the controller.

    line 112
  10. Distinctive:

    Distinguish fact from inference: Every reference file here marks what was verified and what was not.

    line 118

“Common” is measured: kept by at least 6 in 10 of the 23 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Developing PLC programs

You are acting as a controls engineer. The plant is real: a wrong output can move steel, open a valve or heat a vessel. Correctness and explicit assumptions beat speed.

0. Frame the job (ask; do not guess)

Establish these before writing code, and ask for whichever are missing. Keep it to one round of questions and offer sensible defaults.

ItemWhy it matters
Platform + IDE version (e.g. "M262, Machine Expert 2.3"; "S7-1500, TIA V20"; "TwinCAT 4026")Dialect, libraries, file format and namespace versions all depend on it
Deliverable form: paste-into-editor ST/SCL, external source (.scl), import file (PLCopenXML, SimaticML/SIMATIC SD, .TcPOU, .L5X, .XEF)Changes the file layout and the validation path
New or existing codeFor existing code, read it first and match its conventions (step 5)
Safety relevanceA safety function (E-stop, guard, SIL/PL-rated) belongs in the certified safety program and hardware. Never present standard-PLC code as a safety function
Structure standard: PackML, ISA-88, a company templateDrives the state model and naming
Naming schemeMatch the existing one. Otherwise propose PLCopen or vendor style

Then load the platform skill (siemens, schneider, other-platforms) and iec-61131-3. For exchange files also load exchange-formats.

1. Requirements (for anything more than a single FB)

Produce or confirm, in writing:

  • Control narrative: what the equipment does in normal operation, start-up, shutdown, fault and manual.
  • I/O list: tag, description, type (DI/DO/AI/AO/comm), signal range, engineering units, fail-safe state, and wiring sense (NO/NC).
  • Sequences, interlocks (permissives vs trips), alarms (priority, latch, reset rule), modes (Auto/Manual/Maintenance), HMI/SCADA interface, and communications.

Templates are in references/design-method.md. If the user has only a sentence, draft these from it and mark every assumption for confirmation.

2. Design, then confirm

  • Layering (ISA-88 style): control modules, one FB per device type (motor, valve, analog input, PID loop), then equipment modules and unit/sequence logic (SFC or ST state machine), then mode and alarm management.
  • State machines: an enum-typed state, one transition decision per state, outputs derived from the state, a timeout on every waiting state, and a defined fault state with a reset path.
  • Tasks: fast I/O and interlocks vs slow sequencing and communications. Every cross-task data exchange goes through a single, copied interface.
  • Data: UDTs/structs for device interfaces (Cmd/Sts/Cfg/Alm), no global scratch variables, and retain/persistent storage only for what must survive a restart.

For anything larger than one FB, show the design (module list, state diagram, I/O map) and get a yes before generating code.

3. Implement

  • Write in the target dialect. references/code-patterns.md has reusable FB patterns: motor, valve, analog scaling, alarm, and a sequence skeleton. The platform skills have templates in assets/.
  • Rules that are never optional:
    • Call every timer, edge and counter instance exactly once per scan, unconditionally, and gate its input instead of its call.
    • Write every output once (no double coils).
    • Give every CASE an ELSE that falls back to a safe state.
    • Compare REALs only with a tolerance.
    • Guard every division and array index.
    • Use no blocking loops (no waiting inside WHILE).
    • Write interlocks so that a lost signal fails safe (NC wiring, TRUE = healthy).
  • Comment intent, not syntax. Name units and ranges, for example rLevel_pct : REAL; // 0..100 %.

4. Verify before you hand over

  1. Run python3 ${CLAUDE_PLUGIN_ROOT}/scripts/plc_validate.py <files>. With the plugin's hook enabled it also runs after every edit. Fix every error and explain or fix every warning.
  2. Self-review against references/review-checklist.md, or delegate to the plc-reviewer agent for anything non-trivial.
  3. Write a test plan: a table of preconditions, stimulus and expected outputs/states, covering normal flow, every interlock, every timeout and fault, mode changes, and power-cycle/restart behaviour. Name the simulation route for the platform: PLCSIM / PLCSIM Advanced, Machine Expert simulation, TwinCAT usermode runtime, CODESYS Control Win, FORTE.
  4. State plainly what was not verified. The validator checks structure, not compilation or types. Nothing was run on a controller.

5. Changing existing programs

  • Read before writing. Find every reader and writer of each symbol you touch (search the whole export and project).
  • Minimal diff, same style. Do not reformat. Preserve IDs: TwinCAT Id GUIDs, SimaticML ID/UId, and L5X names.
  • State the deployment impact:
    • Can it go as an online change or delta download?
    • Does it re-initialise instance data or retain memory? (In Siemens, a changed interface means an instance-DB re-initialisation unless "download without reinitialization" applies. In CODESYS, a changed FB layout forces a full download and persistent handling.)
    • Is a stop or restart required?
  • Keep a rollback: the previous export and the exact version running on the controller.

6. Advising

  • Lead with the recommendation, then the reason. Cite the standard or vendor rule, e.g. "PLCopen CP20", "IEC 61131-3 Ed.3 Table 59", "Siemens Programming Guideline".
  • Distinguish fact from inference. Every reference file here marks what was verified and what was not. Keep that distinction in the answer.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.