In nature they would just find somewhere on the branch to make the cocoon.
When I am doing a lot of silkworms I use these folding cardboard apartments. They were developed in Japan in the 1960s. They are very practical. They save space and the silkworms are more or less forced to make uniformed sized cocoons.
The silkworms spit silk as they walk around before finding the real estate they prefer and climbing in and making a cocoon. The frames get all dirty with old silk. Instead of using a wire brush to individually clean each compartment it is easier to make an even charcoal fire and add a few pieces of wood for flame and singe off the old silk. It is a little tricky to get the heat and flame just right so that the cardboard doesn't catch fire.
Old silk form last year stuck on the mabushi.