There were really two sub-staffs -- the personal and the professional. The personal took care of the general's personal needs -- getting the HQ tents located (ADC), mustering and using the couriers (AAG), writing, recording and dispatching letters and orders (AAG), ensuring the general was fed (ADC), ensuring the HQ got packed and on the road during movement (ADC). The personal staff was usually near the general for his immediate call. ADC = Aide de camp, AAG = Assistant Adjutant General (military secretary)
The professional staff (Engineer, Commissary, Ordnance, Quartermaster, etc) acted as the connection between the general's plans and their special area of responsibility.The QM, for example, ensured that the required supplies of uniforms and fodder were requisitioned and positioned to support the general's plan of action. He would supervise the professional actions of his junior officers in his branch (ie making sure quarterly reports were filed on time and correctly) and ensured that the level below him knew their part of the operation (ie where the supply depots were and when they would be changed).
The professional staff spent much of their time during a campaign away from the general, seeing to the details of their profession (ie the engineer officer laying out lines of fortification, ensuring the bridging team got to the river at the right time and place, etc).
Generals who wanted small staffs put a lot of the work on the Chief of Staff. This position was, in the CW, more frequently found at the Department level than in the field.
As noted in an earlier post, higher HQ frequently provided some professional staff work. The regiment would not have an engineer officer, for example. But a regiment would have a quartermaster, a commissary and a surgeon.