We designed a soil-inspired chemical system that consists of nanostructured minerals, starch granules and liquid metals. The soil-inspired material possesses chemical, optical and mechanical responsiveness to yield write–erase functions in electrical performance. The composite can also modulate bacterial growth both in vitro and in vivo, such as enriches gut bacteria diversity, rectifies tetracycline-induced gut microbiome dysbiosis and ameliorates dextran sulfate sodium-induced rodent colitis symptoms within rodent models.