By convention, a system that expands (smaller volume -> bigger volume) does positive work.

In a PV diagram the work done equals the area under the curve of P vs V. so if the system starts at a smaller V and goes to a larger V the work just equals the area under the graph (and area is always positive ). If the system does the reverse and goes from larger volume to smaller volume, then the work equals the negative of the area under the graph.

For a closed loop, the work done equals the area enclosed by the loop. You determine whether its positive or negative based on the direction. Clockwise gives positive work, and counter clockwise gives negative work.