You're thinking of the Claws series of two novelettes by Philip K. Dick. The first (and more famous) story is "Second Variety", which is available at Project Gutenberg. It inspired two movies, Screamers (1995) and the sequel Screamers: The Hunting (2009). The sequel is called "Jon's World". The two claws stories appeared together (among many others) in Dick's 1987 collection Second Variety.
Here's a portion of the Wikipedia summary of "Second Variety" (see also the long detailed review at Philip K. Dick Review):
"Second Variety" occurs in the aftermath of an extensive nuclear war between the Soviet Union (sometimes referred to as Russia) and the United Nations. Early Soviet victories forced the North American government and production to flee to a Moon Base, leaving the majority of their troops behind. To counter the almost complete Soviet victory, U.N. technicians develop robots, nicknamed "claws" —the basic models are "a churning sphere of blades and metal" that ambush their unsuspecting victims "spinning, creeping, shaking themselves up suddenly from the gray ash and darting toward… [any warm body]." U.N. forces are protected from the claws by a special radiation-emitting wrist tab. Within six years, the sophisticated and independent claws have destroyed the Soviet forces, repairing and redesigning themselves in automated underground factories run without any human oversight.
The U.N. forces receive a message from the Soviets asking for a policy-level officer to go to them for a gravely urgent conference. The U.N. victory was costlier than they had expected. Major Joseph Hendricks is sent to negotiate with the Soviets. En route to the rendezvous, he meets a small boy named David who asks to accompany Hendricks. When they near the Soviet bunker, soldiers immediately kill the boy, revealing him to be an android. The claws' development program has evolved to develop sophisticated robots, indistinguishable from humans, designed to infiltrate and kill. The three Soviets met by Major Hendricks—soldiers Klaus, Rudi, and a young woman named Tasso—reveal that the entire Soviet army and command structure collapsed under the onslaught of the new robots - they are all that are left in the command center.
Here's the beginning of a long review of "Jon's World" at Philip K. Dick Review:
Kastner and Caleb Ryan are reviewing a recently completed time machine. While it works, it has an unfinished look, which many functional but unattractive knobs. Krastner tells him that he will accompany Ryan on his mission since he always wanted to see what things were like before the war. He will also function as the representative of the United Synthetic Industries Combine, which backed the project. Ryan is requested back at his home because of an attack his son suffered.
He travelled home on an inter-city ship and observes the damage from the war. The cities were built from materials brought down from the Lunar Base, but most of the surface of the planet has been devastated by the war. During the war the surviving humans endured on the Moon while the claws, man-made and autonomous machines, struggled for domination over the planet. (Note: This story is a sequel to “Second Variety” and gives humans a victory over the claws in the end.) When he arrived at City Four, he entered his quarters and discussed the situation with an old man who was seeing to his son. The old man reports that the attack involved his son talking in another voice. In a mature tone, the boy, Jon, talks to his father, asking about the progress on the time ship. Jon reminds his father that the attacks are visions, more real than the world around him. The devastated world is not real. Ryan is concerned about these attacks because they suggest a return to the irrational days of humanity’s infancy and youth, more common to the Middle Ages than to the mature modern age. Jon explains that in his vision the Earth is a pastoral paradise, with animals. People live in an agrarian society, without factories, business, or commerce. Due to his upcoming time trip, Ryan is convinced he must commit his son to a lobotomy.
After the lobotomy, which ended Jon’s visions, Ryan returns to plans for the time trip. The goal is to secure the papers of a scientist Schonerman, who developed the artificial brain used in the claws. This technology was lost when the claws were destroyed. Ryan repeats his concern that reviving this technology may bring the claws back. Kastner insists that technology is value neutral and the only thing that matters is how the technology is used. Ryan makes some final arrangements for his son’s care and then leaves on the time ship with Kastner. During the trip, Ryan and Kastner discuss the first submarine used in the American Revolution and some of the issues involved in time travel. They stop at a point in time while the war against the claws was still going on, observing a unit of “Wounded Soldier” type claws. These were used in the war to infiltrated bunkers. Ryan explains how the Lunar Base survived the claws because the four types were identified and the survivors took precautions against them. They make another stop and narrowly avoid being attacked by a military (Soviet or UN). With the stops required for observation points ended, Ryan and Kastner leave the ship. They are a few miles from the village where Schonerman worked.