Moving skeleton bones according to local coordinates

Hello guys,
I’m trying to manually move the bones of a skinned mesh, with no success.

I created a cube mesh for every bone of a skeleton of a skinned mesh, assigning them the position of bone.getWorldPosition(), this works ok.

I can freely move the cubes, just by changing their position somehow.

I’d then like to “sync” the bones positions with their corresponding cubes ones.
What is the correct way? I know it will need some transformations, but I really suck at this.

Thank you.