You can use python to create scripts for Krita software.
You can use Tools - Script - Scripter from the main menu to write your python script.
I don't use often this python module, but today I created this script.
The script creates a new document with size 512x512 named Python test document.
After that create a duplicate of the layer named Background.
The new layer is named the new Layer duplicate.
from krita import *
from krita import Krita
print(dir(krita))
print(help(Krita))
d = Krita.instance().createDocument(512, 512, "Python test document", "RGBA", "U8", "", 120.0)
Krita.instance().activeWindow().addView(d)
print(dir(d))
print(Krita.instance().filters())
node_name = 'Background'
node = d.nodeByName(node_name)
print(node.name())
print(dir(node))
d_n = node.duplicate()
print(dir(d_n))
d_n.setName("new Layer duplicate")
print(d_n.name())
root_node = d.rootNode()
print(help(root_node.addChildNode))
root_node.addChildNode(d_n, node)