I am currently watching Deutschland 83 and the East German intelligence corps seem to have quite a lot of freedom in conducting espionage, but at the same time appear to ultimately take orders from Moscow. Was there a formal system or hierarchy of Communist spy agencies? P.S. As a side note, this is a fantastic subreddit and love what you do here, apologies if this has been asked previously.
There wasn't a formal hierarchy, but the KGB loomed large over all of the Warsaw Pact intelligence services, and its primacy was undisputed. Soviet intelligence personnel had a hand in creating all of the Eastern Bloc secret services, and KGB liaison officers were a constant and powerful presence in those agencies' affairs.
The Warsaw Pact intelligence agencies provided a constant stream of intelligence to the Lubyanka, along with extensive operational and logistical support. The KGB maintained a shared database of contacts and intelligence called SOUD, enabling them to receive and index intelligence from the Warsaw Pact services (and to share intelligence with them in turn — something they generally did only in the most circumspect manner.)
The KGB frequently used those services as their proxies, especially when it came to handling sensitive or potentially compromising relationships or operations — particularly those with terrorist and revolutionary groups. The Czechoslovak StB, for example, was a longstanding liaison between Moscow Centre and the Italian Red Brigades; the Bulgarian DS was a favourite weapon for 'special tasks'.
The relationship with the Stasi (in particular the foreign intelligence department, HVA), however, was by far the closest and most important to Moscow. Many of the senior figures in the Stasi had longstanding ties to the USSR, as agents or operatives of Soviet intelligence or the Comintern: Wilhelm Zaisser, Ernst Wollweber and Erich Mielke, three of the GDR's four Ministers of State Security; Markus Wolf, the longtime chief of the HVA.
As with many of the institutions of East Germany, the Soviets were heavily involved in the creation of the Stasi (which was closely patterned on the KGB.) The KGB maintained a number of facilities in the GDR, including highly important rezidentura (the largest KGB installation outside the USSR) at Karlshorst. KGB officers regarded East Germany as a safe, even dull posting; as a First Chief Directorate officer in the late 1980s, Vladimir Putin was reportedly disappointed to be assigned to the rezidentura at Dresden, rather than a more interesting and adventurous station in the West.
Part of the reason the Stasi were so important to Moscow was their proximity and access to West Germany and the rest of Western Europe, but it was also thanks to a general reputation for competence and ideological reliability, and a willingness to subordinate their foreign policy/intelligence objectives to those of Moscow. They were thus also entrusted with operations further afield. The Stasi worked alongside the KGB in Cuba, training Castro's intelligence service, DGI — which, in turn, was the preferred Soviet proxy for operations in Latin America. In 1972, when Egyptian strongman Anwar Sadat expelled Soviet (read: KGB/GRU) advisors, the Stasi acted as Soviet surrogates in that crucial Arab state.
There's a reasonably large body of writing on the history of the Stasi now — largely thanks to the concerted effort by the post-unification German government to preserve and open up the Stasi archives. There's a lot of interesting information on the website of the Federal Commissioner for the Stasi Records. In terms of published work: John Schmeidel's monograph Stasi: The Sword and the Shield of the Party is a good place to start. Gary Bruce's The Firm: The Inside Story of the Stasi is a good grassroots history. Kristie Macrakis' Seduced by Secrets: Inside the Stasi's Spy-Tech World is an interesting specialist history of the Stasi's technical methods and surveillance prowess.
On Soviet intelligence, I always suggest starting with Christopher Andrew's work on the KGB: The Sword and the Shield: The Mitrokhin Archive and the Secret History of the KGB and The World Was Going Our Way: The KGB and the Battle for the Third World. Jonathan Haslam's more recent Near and Distant Neighbours is a good history of the Soviet intelligence community as a whole.