How to create a workflow that automates some repeated tasks

How to create a workflow that automates some repeated tasks? For example i have files that store amazon state machines in ASL(Amazon states language) format. There is a way I want to configure all my state machines that is dependent on both a design choice and aws infrastructure as code written using cdk. I would like for the AI to be automatically updating my ASL code based on code changes I make in another file and other custom commands that I may have. Is there a way to do this? Also in auto-complete I would like to tell the AI what files it should be getting context from, so that it knows that for this kind of file there are "sibling " files I can get context from.

Maybe you can use cursorrules for that.