Mime skill?

I am trying to create a skill that functions as Mime does in Final Fantasy where the last action done is repeated. Well, it functions a little differently where the one with the skill can mimic an action done either by an ally or an enemy. How would I go about doing that?
I guess it works just like this with VS Battle Core skill notetag:

<JS Pre-Start Action>
if ($gameTemp.lastActionData(0))
this.setSkill($gameTemp.lastActionData(0));
</JS Pre-Start Action>

Though the last skill used carries over from previous battle or map, so if you don't want that, you'll have to add extra conditionals.
That may not be a problem with the boss I want to use it on since he will most likely not act first, and the actor I would want to use it on also probably wouldn't have that as an issue.

Original thread: https://forums.rpgmakerweb.com/threads/mime-skill.182860/