Most of the existing underwater image object detection methods involve pre-processing, such as using underwater image enhancement, to improve the accuracy of object detection. However, pre-processing methods are designed to improve the subjective perception of the human eye, which does not necessarily improve the object detection performance and consumes a large amount of computational resources. Therefore, in this paper, we creatively combine these two tasks and propose a Shape-Guided Detection network (SGD) to simultaneously optimize underwater image enhancement and object detection. In the SGD network, we innovatively incorporate the prior shape features as a learnable module embedded in it to fully explore the shape characteristics and structural details of the target object. To ensure that the prior knowledge can be effectively fused into the global network structure, we design a Shape Prior Enhancement module, which aims to realize the deep integration of the prior information with the local details. In order to optimize the stability of model training and enhance its convergence performance, a dual strategy of explicit and implicit constraints is ingeniously proposed in our method. We conduct extensive experiments on public datasets and the results show that the combination of our method with different detectors significantly improves the performance. The object detection performance reaches up to 0.491 mAP for optical images and 0.576 mAP for sonar images, and improves the preprocessing speed by 0.1 s.