The Commander, Air Group, or CAG position is a hold over from the United States Navy of 1940s Earth. This officer, who filled a Captain's Billet, was in charge of an Aircraft Carrier's entire Air Group ranging anywhere from a hand full to a hundred aircraft. The CAG was the most senior member of the airwing, and was expected to lead all major strike operations. in the 1970s The terminology was changed and the Carrier Air Group became known as a Carrier Air Wing or CVW,but the position of CAG was retained. Shortly after, the position of CAG became co-equal to the Carrier's Commanding Officer, Both of whom reporting directly to the Flag Officer in command of the entire Carrier Battle Group.
With the advent of warp powered spacecraft in the late 21st and early 22nd Centuries, the need for a space bourne fighter craft which could accompany a large fleet was recognized, and the Yorktown-class carrier, with it's Minotaur Fighter, was fielded in the latter half of the Earth-Romulan War although, each Carrier only carried five of the fighters and an additional compliment of Shuttlepods, Earth Starfleet assigned each an officer equivalent to a department head, known as the Carrier Space Wing Commander, who would be in charge of the Space Wing, the position was informally referred to as the CAG, and the name stuck.
By the 2380s the CAG's position, now organized under the banner of Starfleet Fighter Command had remained essentially unchanged, but in 2381 Starfleet Command elevated the position to replace the Executive Officer on a Carrier, essentially giving them an elevated status over the other department heads, and a closer working relationship with the CO. (Star Trek: New Order)
The CAG's immediate subordinate is the Deputy CAG or DCAG for short. this is the second most senior officer in the Space wing, in the US Navy, this position was also a Captain's Billet, although, they are still subordinate to the CAG. In Starfleet the DCAG position is not necessarily the same rank as the CAG, and often serves as one of the squadron CO's although he is superior to the others. Under the 2381 reorganization, the DCAG assumed the role of second officer and an Lieutenant Commander billet. (Star Trek: New Order)
The Squadron Commander is the officer in direct command of one of the squadrons in a given carrier's space wing, they report directly to the CAG and/or DCAG. The position is usually occupied by one of the squadron's pilot's although Weapons Systems Officers and Copilots can also occupy this position. if a squadron flies multi-crew craft, the squadron's XO usually flies in the same one as the CO. Each squadron is considered a fully fledged crew in it's own right, each one possesses a command structure, containing a Commanding officer, an Executive officer, a Squadron Intelligence officer, a Tactical officer, an Operations manager, a Science officer and an Engineer. The Squadron CO is a Lieutenant Commander billet, although, they are still subordinate to the DCAG who holds the same rank. When operating from a planetside facility, or a Starbase, while independent of a wing, the Squadron may be commanded by a full Commander, who also performs the duties of de-facto CAG. (Star Trek: New Order)